zerbfra
zerbfra

Reputation: 190

NSUbiquitousKeyValueStoreDidChangeExternallyNotification not fired with ad hoc distribution

I have the code here reported. The problem is that with my development device it works perfectly, it wait for iCloud and then the method iCloudSync is called and it works.

With an ad hoc profile for a beta testing user it doesn't work because (i think - because the logging of the method iCloudSync is not present in console) the NSUbiquitousKeyValueStoreDidChangeExternallyNotificationis not fired.

Where I'm wrong? Thanks

/******** GESTIONE ICLOUD ************/

NSUbiquitousKeyValueStore *iCloudStore = [NSUbiquitousKeyValueStore defaultStore];

if(iCloudStore)
{

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(iCloudSync)
                                                 name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
                                               object:[NSUbiquitousKeyValueStore defaultStore]];


    [iCloudStore synchronize];
    [[NSUserDefaults standardUserDefaults] setBool:TRUE forKey: iCloudEnabled];

}
else
{
    NSLog(@"iCloud is not enabled");
    [[NSUserDefaults standardUserDefaults] setBool:FALSE forKey: iCloudEnabled];
    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"iCloud not enabled" message:@"iCloud is not working" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
    [alertView show];
}

 /******** FINE GESTIONE ICLOUD ************/

Upvotes: 0

Views: 353

Answers (2)

Armand DOHM
Armand DOHM

Reputation: 1131

Your selector look wrong, it should have one and only one argument (cf NSNotificationCenter documentation. You should have

selector:@selector(iCloudSync:)     //note the double dot

and your iCloudSync function should look like :

-(void) iCloudSync:(NSNotification *)notification
{
do things...
}

Upvotes: 1

Armand DOHM
Armand DOHM

Reputation: 1131

Can you put a log before and after [[NSNotificationCenter defaultCenter]... to confirm you really set it on your AD Hoc Device ?

PS : is "dev" and "AD HOC" Devices the same device or 2 different devices ? I saw a company where iCloud was not allowed via a profil. The users were not able to set iCloud enable....

Upvotes: 0

Related Questions