2014-11-03 12 views
9

Ho un'app che utilizza le notifiche locali e ti ha usato per funzionare correttamente nelle versioni precedenti. Ho aggiornato l'app per iOS 8 e ho testato e funzionato correttamente. Dopo aver inviato l'aggiornamento all'app store, un numero limitato di utenti si lamenta di non ricevere alcuna notifica locale. Tuttavia, un numero maggiore di utenti che ho controllato va bene e non rileva alcun problema.Notifiche locali non funzionanti per alcuni utenti (iOS 8)

Per gli utenti con l'errore (almeno uno di essi), non possono vedere la voce "Notifiche" nella schermata "Impostazioni-> MiaApp"; L'intera opzione non è mancante che sia disabilitata. "Location" e "Use Cellular Data" si trovano in quella schermata ma non nelle Notifiche. Ho provato a modificare le impostazioni in "Impostazioni-> Notifiche-> myApp" e funziona come previsto.

Qualsiasi suggerimento su come eseguire il debug di questo problema sarebbe molto utile. Grazie!

+0

Stesso problema: http://stackoverflow.com/questions/20180806/app-with-local-notifications-not-appearing-in-notification-center-list-in-settin?rq=1 – Mikrasya

+0

Same problema (altro): http://stackoverflow.com/questions/25827650/app-from-app-store-doesnt-show-up-for-all-users-under-notification-center-loca?rq=1 – Mikrasya

+1

I avere lo stesso problema Sono contento di vedere che non sono solo. Spero che qualcuno trovi presto una risposta. – dadThrowsBolts

risposta

8

Prova questo per Objective-C:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions 
{ 
// are you running on iOS8? 
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) 
    { 
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound) categories:nil]; 
    [application registerUserNotificationSettings:settings]; 
    } 
else // iOS 7 or earlier 
    { 
    UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; 
    [application registerForRemoteNotificationTypes:myTypes]; 
    } 
} 

Per Swift:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { 
// Override point for customization after application launch. 
if(UIApplication.instancesRespondToSelector(Selector("registerUserNotificationSettings:"))) 
{ 
    application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil)) 
} 
else 
{ 
    // 
} 
return true 
} 
+2

Grazie. Seleziono questa come risposta corretta poiché questo è stato il primo a rispondere. Prima che queste risposte vengano pubblicate, ho implementato lo stesso codice (registerUserNotificationSettings) e ho chiesto a uno dei miei utenti di testare utilizzando i test Ad-hoc e ha confermato che il problema è stato risolto. ** In iOS 8, anche le notifiche locali devono essere registrate **. – Mikrasya

1

Prima di tutto bisogna registrarsi per utilizzare Local Push Notification

UIApplication *application = [UIApplication sharedApplication]; 
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { 
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]]; 
} 

allora si può inviare una notifica push locale By Questo

UILocalNotification *notification = [UILocalNotification new]; 
notification.alertBody = @"Local Push !!!"; 
notification.applicationIconBadgeNumber=1; 
[[UIApplication sharedApplication] presentLocalNotificationNow:notification]; 
0
void EnableLocalNotificationIOS8 
{ 
    UIApplication *app = [UIApplication sharedApplication]; 

    if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) 
    { 
     UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]; 
     [app registerUserNotificationSettings:settings]; 
     [app registerForRemoteNotifications]; 
    } 
} 
Problemi correlati