Titanium ios contact phone custom labels? - ios

I found a bug in Titanium Appcelerator Studio , the phone object return undefined when the contact object has custom labels for phone number .
Unfortunately they may take more time to fix this issue , but the good news I can modify the build classes of Objective-C , here is the method to provide person information .
inside /build/iphone/classes/TiContactsPerson.m
+(NSDictionary*)multiValueLabels
{
if (multiValueLabels == nil) {
multiValueLabels =
[[NSDictionary alloc] initWithObjectsAndKeys:(NSString*)kABHomeLabel,#"home", // Generic labels
kABWorkLabel,#"work",
kABOtherLabel,#"other",
kABPersonPhoneMobileLabel,#"mobile", // Phone labels
kABPersonPhonePagerLabel,#"pager",
kABPersonPhoneWorkFAXLabel,#"workFax",
kABPersonPhoneMainLabel,#"main",
kABPersonPhoneIPhoneLabel,#"iPhone",
kABPersonPhoneHomeFAXLabel,#"homeFax",
kABPersonSocialProfileServiceFacebook,#"facebookProfile",// Social Profile Labels
kABPersonSocialProfileServiceFlickr,#"flickrProfile",
kABPersonSocialProfileServiceGameCenter,#"gameCenterProfile",
kABPersonSocialProfileServiceLinkedIn,#"linkedInProfile",
kABPersonSocialProfileServiceMyspace,#"myspaceProfile",
kABPersonSocialProfileServiceSinaWeibo,#"sinaWeiboProfile",
kABPersonSocialProfileServiceTwitter,#"twitterProfile",
kABPersonInstantMessageServiceAIM,#"aim", // IM labels
kABPersonInstantMessageServiceICQ,#"icq",
kABPersonInstantMessageServiceJabber,#"jabber",
kABPersonInstantMessageServiceMSN,#"msn",
kABPersonInstantMessageServiceYahoo,#"yahoo",
kABPersonInstantMessageServiceQQ,#"qq",
kABPersonInstantMessageServiceSkype,#"skype",
kABPersonInstantMessageServiceGoogleTalk,#"googletalk",
kABPersonInstantMessageServiceGaduGadu,#"gadugadu",
kABPersonInstantMessageServiceFacebook,#"facebook",
kABPersonMotherLabel,#"mother", // Relation labels
kABPersonFatherLabel,#"father",
kABPersonParentLabel,#"parent",
kABPersonSisterLabel,#"sister",
kABPersonBrotherLabel,#"brother",
kABPersonChildLabel,#"child",
kABPersonFriendLabel,#"friend",
kABPersonSpouseLabel,#"spouse",
kABPersonPartnerLabel,#"partner",
kABPersonManagerLabel,#"manager",
kABPersonAssistantLabel,#"assistant",
kABPersonAnniversaryLabel,#"anniversary", // Date label
kABPersonHomePageLabel,#"homepage", // URL label
nil];
}
return multiValueLabels;
}
It does not include custom label's set by user for phone number , and that's why the phone array return undefined when contact has custom label set.
my question how to get all custom label's created by user and push
them inside above array ?
note : I've reported this bug to appcelerator Jira.
any advice is very much appreciated

The ticket https://jira.appcelerator.org/browse/TIMOB-19739 is closed and released since SDK 5.1.0

Related

Get user_pseudo_id from Firebase iOS SDK

In Firebase Analytics, there is a user property called user_pseudo_id, which is automatically set by Firebase, and it seems to fit our needs.
The doc says:
The pseudonymous id (e.g., app instance ID) for the user.
but when I get Instance ID using InstanceID.instanceID().instanceID(handler:) it give different value from what we see in Big Query.
Any thoughts on how to get it? Thanks!
You should be using the appInstanceID method of FIRAnalytics class.
NSString *instanceID = [FIRAnalytics appInstanceID];
NSLog(#"INSTANCE ID: %#", instanceID);
Using Swift 5 you can get this as follows.
let instanceID = Analytics.appInstanceID()
print(instanceID)

iOS 8.1 Swift Dictionary Error: EXC_BAD_ACCESS (XCode 6.1)

TLDR: I'm getting an EXC_BAD_ACCESS error using swift in XCode 6.1 building for iOS8.1. I believe the issue is likely a compiler error.
I am making an app wherein the user is allowed to add (Korean) words from a dictionary (in the English sense) to a word list. I have the following classes that define a word (with associated definitions, audio files, user-interaction statistics, etc.) and a word list (with an associated list of words and methods to add/remove words to the list, alphabetize the list, etc):
class Word: NSObject, NSCoding, Printable {
var hangul = String("")
var definition = String("")
// ...
}
class WordList: NSObject, NSCoding {
var title = ""
var knownWords = Dictionary<String,String> ()
// ...
func addWordToList(wordName: String, wordDefinition: String) {
// Debug statements
println("I am WordList \"\(self.title)\" and have the following knownWords (\(self.knownWords.count) words total): ")
for (_wordName,_wordDefinition) in self.knownWords {
println("\t\"\(_wordName)\" : \(_wordDefinition)")
}
println("\nI am about to attempt to add the word \"\(wordName)\" with definition \"\(wordDefinition)\" to the above dictionary")
// Add word to wordList, including the 'let' fix
fix_EXC_BAD_ACCESS_bug()
knownWords[wordName] = wordDefinition // EXC_BAD_ACCESS
}
func fix_EXC_BAD_ACCESS_bug() {
// This empty line attempts to solve a exc_bad_access compiler bug when adding a new value to a WordList dictionary
let newDic = self.knownWords
}
// ...
}
Next I have a UITableViewController with a UISearchBar that I use to display the dictionary (again in the English sense) of words to the user. The user adds words by tapping a button (which is displaying an image) on the right of each cell, which calls the #IBAction func addWord() in the viewController:
class AddingWordsToWordList_TableViewController: UITableViewController, UISearchResultsUpdating {
var koreanDictionary = KoreanDictionary() // Custom class with method 'getWord(index: Int)' to return desired Word
var filteredSearch = [Word]()
// ...
// Add word
#IBAction func addWord(sender: UIButton) {
// Add word
if self.resultSearchController.active {
let word = filteredSearch[sender.tag]
wordList.addWordToList(word.hangul, definition: word.definition) // Enter addWordToList() here
} else {
let word = koreanDictionary.getWord(sender.tag)
wordList.addWordToList(word.hangul, definition: word.definition)
}
// Set image to gray
sender.imageView?.image = UIImage(named: "add133 gray")
// Save results
wordList.save()
// Reload table data
tableView.reloadData()
}
// ...
At first the app compiles and seems to run fine. I can add a new word list and start adding words to it, until I add the 8th word. I (always on the 8th word) get a EXC_BAD_ACCESS error in (WordList) addWordToList with the following println information:
I am WordList "School" and have the following knownWords (7 words total):
"방학" : school vacation
"대학원" : graduate school
"학년" : school year
"고등학생" : high school student
"초등학교" : elementary school
"학생" : student
"학교" : school
I am about to attempt to add the word "대학생" with definition "college student" to the above dictionary
Note that the order in which I add the words appears irrelevant (i.e. the word "college student" can be added successfully if it is one of the first 7 words). There is nowhere in the code where I explicitly change behavior based on the number of words in a word list (except to display the words in a word list as cells in a UITableView), or any dependencies that would (to my knowledge) make the 8th word a special number. And indeed this number can change by using the let hack= solution (see below) to a different number, but for a particular build is always the same number.
At this point I'm at a complete loss of what to do. I'm relatively new to swift and have spent quite a few hours looking up how to fix exc_bad_access errors. I've come to the following point:
It seems exc_bad_access errors usually mean one of three things (http://www.touch-code-magazine.com/how-to-debug-exc_bad_access/)
An object is not initialized
An object is already released
Something else that is not very likely to happen
I don't feel like either 1 or 2 can be the case for me, as right before we get the access error we can print out the contents of the dictionary in question (knownWords). However, as is always the case it is highly likely I'm missing something obvious, so please let me know if this is indeed true.
If the error is caused by 3 above ("something else") I have tried the following:
(From EXC_BAD_ACCESS on iOS 8.1 with Dictionary and EXC_BAD_ACCESS when updating Swift dictionary after using it for evaluate NSExpression solutions)
I have tried different variations of the let stupidHack = scenario, and it does sometimes change the results, but only the number of entries allowed before crashing (i.e. I can sometimes get to the ~15th/16th entry in the dictionary before the error). I have not been able to find an actual, bug-free solution using this method, however.
I have rebuilt using both Release and Debug modes; the error appears in both. Note I am only using the simulator and do not have a developer's license to try it on an actual device.
I have turned off (set to "None") compiler optimization (it was already off for the Debug build anyway).
I have tried building to iOS 8.0 with the same error results.
Any way to get around this issue is appreciated. A let hack = solution is acceptable, but preferably a solution will at least guarantee to not produce the error in the future under different build conditions.
Thanks!

Google+ API in iOS, GPPShare recipient setting

I am trying to integrate GooglePlus inside an iOS app of mine.
The app sends a simple message. I have a few questions about the setting of the recipient(s).
Here is the kind of code I am using:
[GPPShare sharedInstance].delegate = self;
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder setPrefillText:#"Hello world! How is everything?"];
[shareBuilder setPreselectedPeopleIDs:#"112233445566778899000"]; // Question point!!
if (![shareBuilder open]) {
NSLog(#"Status: Error (shareBuilder cannot open).");
}
When the line with the comment "Question point!!" is present, I can set one(or a few) individual(s) as recipient(s) of the message.
When it is not present the set of recipients defaults to "Friends".
Here are my two questions:
Is it possible to set one of my circles (or a community) as recipient? Not only "Friends".
When using the "setPreselectedPeopleIDs:" method, one needs the ID of the recipient. How do we find this ID? There are documents and videos on the net showing how to find one's own ID, but since people usually send messages to other peole rather than to themselves, it would also be useful to know how to get other's IDs.
Doesn't seem like you can share with a specific circle.
You can use this method to get all of the visible people in the user's circles using this method
queryForPeopleListWithUserId:collection:
which is outlined here:
https://developers.google.com/+/mobile/ios/people
Explanation of the parameters from the header:
// List all of the people in the specified collection.
// Required:
// userId: Get the collection of people for the person identified. Use "me" to
// indicate the authenticated user.
// collection: The collection of people to list.
// kGTLPlusCollectionVisible: The list of people who this user has added to
// one or more circles, limited to the circles visible to the requesting
// application.
And another question that goes into this a little bit:
How to Fetch Google Plus circles in IOS Sdk
It does not seem to me like you can discern who is in what circle, unfortunately.

iOS Autocomplete UITEXTVIEW | Add autocomplete suggestions dynamically

I've been trying to implement an autocomplete UITEXTVIEW for my email app using this
https://github.com/hoteltonight/HTAutocompleteTextField
I would like to add the email addresses dynamically though. Is there any way to achieve the same. Because when I checked, the email addresses are initialised at start as given below.
HTEmailAutocompleteTextField.m
- (void)setupAutocompleteTextField
{
[super setupAutocompleteTextField];
// Default email domains to suggest
self.emailDomains = #[ #"gmail.com", #"yahoo.com"];
self.autocompleteDataSource = self;
}
The above method is called from HTAutocompleteTextField.m[- (void)awakeFromNib] as soon as the app is launched thereby not letting me to add email addresses dynamically.
Is there any work around because I get my email addresses later.
Any help is much appreciated.
Have you tried this from GitHub readme
HTAutocompleteTextField *textField = [[HTAutocompleteTextField alloc] initWithFrame:CGRectMake(0,0,100,31)];
The data source is the brains of the autocomplete logic. If you just want to autocomplete email addresses, use HTAutocompleteManager from the example project as follows:
textField.autocompleteDataSource = [HTAutocompleteManager sharedManager];
textField.autocompleteType = HTAutocompleteTypeEmail;
Alternatively, you may wish to create your own data source class and user the autocompleteType property to differentiate between fields with different data types. A HTAutocompleteTextFields's data source must implement the following method, as part of the HTAutocompleteDataSource protocol.
-(NSString *)textField:(HTAutocompleteTextField *)textField completionForPrefix:(NSString *)prefix ignoreCase:(BOOL)ignoreCase

Is Twitter sharing broken under iOS 7? (Example project attached.)

Example project: http://cl.ly/261z1P100T25
Under iOS 7, when I try to add a URL to a tweet, the method should return NO if there's no enough space to add it ("This method returns NO if url does not fit in the currently available character space") but this method ALWAYS returns YES in iOS 7. For example, in the following example, "Couldn't add." is never printed and the tweet is presented with -32 characters remaining.
SLComposeViewController *twitterViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
NSString *titleToShare = #"i am a string a super string the most super string that ever existed in the world of the super string universe which as it happens is very super as well";
if (titleToShare.length > 140) {
titleToShare = [titleToShare substringToIndex:140];
}
[twitterViewController setInitialText:titleToShare];
if (![twitterViewController addURL:[NSURL URLWithString:#"http://google.com"]]) {
NSLog(#"Couldn't add.");
}
[self presentViewController:twitterViewController animated:YES completion:nil];
Is it broken? Do I have to code around this?
It's not broken, just it isn't publicly documented well. I found in code following comment for setInitialText: method:
// Sets the initial text to be posted. Returns NO if the sheet has already been
// presented to the user. On iOS 6.x, this returns NO if the specified text
// will not fit within the character space currently available; on iOS 7.0 and
// later, you may supply text with a length greater than the service supports,
// and the sheet will allow the user to edit it accordingly.
So, they allow you to set text greater then 140 characters, just you can't post this text because post button is disabled.

Resources