2016-09-26 4 views
0

ich lokale Benachrichtigung auf iOS 9.x am Planen und aktualisieren Sie das Gerät auf iOS 10.Lokale Meldung erscheint nicht nach dem Upgrade von iOS 9.x auf iOS 10

Schritte:

  1. Register lokalen Benachrichtigung in iOS 9.x
  2. Schedule lokale Benachrichtigung auf iOS 9.x
  3. Beenden app
  4. Upgrade-Gerät auf iOS 10
  5. Warten lokale Benachrichtigung zu zeigen, aber es funktioniert nicht

-Code unten erscheinen:

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

Schedule Benachrichtigungscode In didFinsihLaunchingWithOptions

sich wie folgt: if (errorRef != NULL) { *errorRef = nil; }

UILocalNotification * localNot = [[UILocalNotification alloc] init]; 
localNot.userInfo = [NSDictionary dictionaryWithObjectsAndKeys: 
        self.reminderId, REMINDER_ID_KEY_IN_LOCAL_NOTIF, 
        aOcc.repeatId, REPETITION_ID_KEY_IN_LOCAL_NOTIF, 
        @(index), SNOOZE_INDEX, 
        nil]; 

localNot.fireDate = [NSDate dateWithTimeInterval:(index * SNOOZE_INTERVAL * 60) sinceDate:aOcc.startTime]; 
localNot.repeatInterval = aOcc.repeatInterval; // NSCalendarUnitWeekOfYear 
localNot.timeZone = aOcc.timeZone; // system timezone 


if (aOcc.messageStr != nil && [aOcc.messageStr length] > 0) 
{ 
    localNot.alertBody = aOcc.messageStr; 
} 

if (self.soundFlag == YES) 
{ 
    if (self.soundFileName != nil && [self.soundFileName length] > 0) 
    { 
     localNot.soundName = [[NSString alloc]initWithFormat:@"%@.%@",self.soundFileName,kDefaultSoundFileExtension]; 
    } 
} 

[[UIApplication sharedApplication] scheduleLocalNotification:localNot]; 

if (aOcc.snoozeArray == nil) 
{ 
    aOcc.snoozeArray = @[localNot]; 
} 
else 
{ 
    aOcc.snoozeArray = [aOcc.snoozeArray arrayByAddingObject:localNot]; 
} 
[self.repetitions setObject:aOcc forKey:aOcc.repeatId]; 
[[RemindersManager sharedInstance] save]; 
return localNot; 

Nach tiefen Einblick in Protokolle, Ich finde Instanz von Sep 28 18:44:05 iPhone SpringBoard (UserNotificationsServer) [57]: [XXXXXXXXXX] Benachrichtigungen aktivieren: 0 [authorizationOptions: 7]

Bitte helfen Sie. Danke im Voraus.

Antwort

1

Dieser Code von Ihnen funktioniert nicht für iOS10. Sie müssen sich für iOS10 folgende verwenden:

UserNotifications framework 
Verwandte Themen