Game Development Reference
In-Depth Information
[[NSNotificationCenter defaultCenter]
addObserver:selfselector:@selector(iCloudAccountAvailabilityChanged:)name:NSUbiquityIdentityDidChangeNotification
object:nil];
6. After archiving the iCloud token and registering the iCloud notification, our app
is ready to show an alert view in order to show invites to the user iCloud with two
options: local only and use iCloud. For this, first of all save a Boolean variable for
FirstLaunchWithiCloudAvailable when the token is retrieved:
BOOL firstLaunchWithiCloudAvailable =
[[NSUserDefaults standardUserDefaults]
objectForKey:@"FirstLaunchWithiCloudAvailable"];
if (firstLaunchWithiCloudAvailable == NO)
{
[[NSUserDefaults standardUserDefaults]
setObject:[NSNumber numberWithBool:YES]
forKey:@"FirstLaunchWithiCloudAvailable"];
}
[[NSUserDefaults standardUserDefaults] synchronize];
7. Also, call a method showiCloudInviteAlertView always in didFin-
ishLauchingWithOptions . In this method, show the alert view to invite
the user to use iCloud if a current token exists (it will exist only if the user is
logged in to the iCloud Account, otherwise NIL will be returned) and also if the
FirstLaunchWithiCloudAvailable bool is YES.
- (void)showiCloudInviteAlertView
{
BOOL firstLaunchWithiCloudAvailable =
[[NSUserDefaults standardUserDefaults]
objectForKey:@"FirstLaunchWithiCloudAvailable"];
if (currentiCloudToken &&
firstLaunchWithiCloudAvailable)
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle: @"Choose Storage Option" message:
@"Should documents be stored in iCloud and available
on all your devices?"
delegate: self
Search WWH ::




Custom Search