1

ios7에서 ios8.1로 내 장치를 업데이트했습니다. 푸시 알림이 업데이트 된 버전에서 작동하지 않습니다. ios7에서 수행 된 푸시 알림에 대해 동일한 프로세스를 수행했습니다. 코드는 또한 위의 코드를 사용하여 ios7에서 ios8.1로 업데이트 된 버전에서 푸시 알림이 작동하지 않습니다.

#ifdef __IPHONE_8_0 
     //Right, that is the point 
     UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge 
    |UIUserNotificationTypeSound 
    |UIUserNotificationTypeAlert) categories:nil]; 
     [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
#else 
    //register to receive notifications 
    UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; 
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes]; 
#endif 

업데이트됩니다 또한 내가 ios8.1에서 푸시 알림을 도와 notification.Please 수 didnot.

덕분에

답변

3

inadvance 푸시 알림을 수신하는 방법도 변경되었습니다

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier 

더 많은 정보를 원하시면 Handling Local and Remote NotificationsUIApplicationDelegate를 참조하십시오. 내 경우에는

- (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { 
     NSLog(@"Requesting permission for push notifications..."); // iOS 8 
     UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: 
      UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | 
      UIUserNotificationTypeSound categories:nil]; 
     [UIApplication.sharedApplication registerUserNotificationSettings:settings]; 
    } else { 
     NSLog(@"Registering device for push notifications..."); // iOS 7 and earlier 
     [UIApplication.sharedApplication registerForRemoteNotificationTypes: 
      UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | 
      UIRemoteNotificationTypeSound]; 
    } 
    return YES; 
} 

- (void)application:(UIApplication *)application 
    didRegisterUserNotificationSettings:(UIUserNotificationSettings *)settings 
{ 
    NSLog(@"Registering device for push notifications..."); // iOS 8 
    [application registerForRemoteNotifications]; 
} 

- (void)application:(UIApplication *)application 
    didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token 
{ 
    NSLog(@"Registration successful, bundle identifier: %@, device token: %@", 
     [NSBundle.mainBundle bundleIdentifier], token); 
} 

- (void)application:(UIApplication *)application 
    didFailToRegisterForRemoteNotificationsWithError:(NSError *)error 
{ 
    NSLog(@"Failed to register: %@", error); 
} 

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier 
    forRemoteNotification:(NSDictionary *)notification completionHandler:(void(^)())completionHandler 
{ 
    NSLog(@"Received push notification: %@, identifier: %@", notification, identifier); // iOS 8 
    completionHandler(); 
} 

- (void)application:(UIApplication *)application 
    didReceiveRemoteNotification:(NSDictionary *)notification 
{ 
    NSLog(@"Received push notification: %@", notification); // iOS 7 and earlier 
} 
+0

작동하지 : 여기

는 응용 프로그램 위임의 전체 예입니다? 나는이 새로운 변화에 관한 어떤 문서도 찾지 못했습니까? 유용한 링크를주세요. – iphonemaclover