CallDirectoryHandler IOS10 nsuserdefaults - ios10

I've been trying to use the new CallDirectoryHandler extension for IOS10
I'm using the official release.
First of all this extension is not debuggable and logs doesn't seems to work.
I'm trying to pass Parameters between my app to this extension via NSUserDefaults, it's not working the object that I get is empty.
Anyone has any idea how to pass parameters otherwise for this extension?
Thanks

Using Application groups solved my problem.
NSUserDefaults *mySharedDefaults = [[NSUserDefaults alloc] initWithSuiteName: #"group.name.company.shared"];

Related

iOS - Prompt User to Update to Latest App Version

Is there any method or plugin available that will alert the user to upgrade an app if the version they are using is not the latest? I suppose I could ping a web service to check what the current version is and compare with the user's version and go from there. As an aside, is there a way to check the current version of the app (some property I don't know about) or do you simply have to hardcode the version as some float variable or something?
Thanks
There's a nice little open source library available called Harpy that will accomplish this for you! It provides the ability to check for updates on startup, daily, or weekly, and it uses itunes to do the checking, so config is really minimal.
you will need to build the update check functionality yourself. however you can get the version info from the app.
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];
Bear in mind tho that just because you have an app up. and it has been released into the store. that does not mean the app is immediately available to all users via the app store.
There is update version of harpy called siren that will help you. Below is the link,
https://github.com/ArtSabintsev/Siren
You'll have to build such a solution yourself. There's no update-checking functionality provided by the iOS SDK.
Most apps just check a website or similar, as you've already considered.
You can grab the version from the info.plist with
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
self.applicationVersion = [infoDict objectForKey:#"CFBundleVersion"];
self.applicationBuild = [infoDict objectForKey:#"CFBundleShortVersionString"];
And, yes just hit a web service. Or even easier you could just put a file up on S3 and update that with your version number.

How to maintain app settings when user updates to new version

When we update an application, the settings which are selected by the user in the old version should be kept after updating to the newer version.
Let me explain this with an simple example:
Version 1.0 of my app has a switch that is ON by default but the user can set OFF. In the App Store I am going to publish next version— 1.1—with some modification but it also has the same switch. When the user updates it from the device the switch value should stay OFF.
How can I achieve this kindly reply me with your valuable comments...
Thanx in advance...
You can simply use NSUserDefaults
App 1.1 can easily read what App 1.0 wrote.
When you update your app to a newer version, then the UserDefault have no change (If dont remove app).
Then what we have to do is detect whether your app is updated to a newer version. What I did in my app is maintain a variable in UserDefault like "CurrentAppVersion", then when app is launched I check the currentVersion which getting from app Bundle, if they are difference and up, then I migrate my settings to a new version and update "CurrentAppVersion" to a new version also.
Reference:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
NSString *currentAppVersion = [userDefault objectForKey:#"CurrentAppVersion"];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleVersion"];
NSLog(#"current version: %#, appversion: %#", currentAppVersion, appVersion);
if ([currentAppVersion isEqualToString:appVersion] == NO) {
// Your app has just updated to new version, migrate your app settings.
} else {
// NO, do nothings with your app settings.
}
Hope it help your much, :)
The contents in Application Documents directory and Library directory will not change after app update. So what you should do is just write the settings (say a string "SWITCH:YES") to your Documents directory just like
[string writeToFile:<#(NSString *)#> atomically:<#(BOOL)#> encoding:<#(NSStringEncoding)#> error:<#(NSError **)#>];
see this post Retaining data after updating application
Your 1.1 version just needs to read the saved user settings written by the 1.0 version. This is one reason that putting a versioning mechanism in your saved user data is a good idea, to make this type of upgrade simple.
for sure you are saving your switch value some where on your first version so you can get it and apply it in the next version .. for me when I make update to an app I usually build a backward computability class inside it I retrieve all the user settings and content and call it for the first time the app run and then I apply the old settings on the new version. Good luck

Are values stored in NSUserDefaults removed when the app that put them there is uninstalled?

If I put a token (a string) into NSUserDefaults, lets say as a paramter passed to a REST API that is used by the app, and the app is uninstalled, will the string remain on the device?
No, it will not. I use NSUserDefaults in the exact same manner, and it will not stay after the app is deleted. You can verify this via Organizer if you need to.
It will however persist through updates. I have been using TestFlightApp for all of my beta testing, and the token (and other saved user default data) remains. Hope this helps.
No. You can see that the data saved is in Library/Preferences/ inside your sandbox. If you are using Simulator, see (something like) ~/Library/Application\ Support/iPhone\ Simulator/4.3.2/Applications/00DB5581-E797-4AB0-9033-321ACD8938BD/Library/Preferences/com.me.MyApp.plist

Launch iPhone Application with Identifier

I'm trying to Launch an application within my App.
For example: If I press a Button in my testApp1, it should Open up testApp2.
Is there any Way to do this with the App Identifier??
I heard something about a undocumented method called launchApplicationWithIdentifier: suspend: but that doesn't work for me, or i'm using it wrong.
I tried this:
[UIApplication launchApplicationWithIdentifier:#"com.test.testApp2" suspend:NO]
But it didn't work.
Better use [[UIApplication sharedApplication] openUrl:]. You'll need set a custom URL scheme in your second app for that. Check this tutorial or simply do a search with "iphone custom URL schemes". There's a lot of good tutorials.
I am not sure but i guess launchApplication is used for mac app thats why its showing warning. i will suggest you to create a custom URL and add it to plist file and then later you may launch your app using that url.

SBFormattedPhoneNumber issue in iOS4.0

I am using the below code in my application which works perfectly in iPhoneOS 3.1.3 but not working in iOS 4.0. Any body affected by using this.
NSString *currentPhoneNumber = [[NSUserDefaults standardUserDefaults] objectForKey:#"SBFormattedPhoneNumber"];
It appears that the SBFormattedPhoneNumber key/value data has been removed from the NSUserDefaults object as of 4.0. No device number retrieval love; can't really say that the writing wasn't on the wall based upon Dylan's response to this thread.