2014-12-11 2 views
-1
/*--- Setup Push Notification ---*/ 
    //For iOS 8 
    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)] && [UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)]) 
    { 
     UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]; 
     [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
    } 
    //For iOS 7 & less 
    else if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotificationTypes:)]) 
    { 
     UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; 
     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes]; 
    } 

안녕하세요! 누군가가 나를 도울 수 있기를 바랍니다. iOS8에 대한 푸시 알림을 받으려면 코드를 업데이트했습니다. iOS8 기기에서 모든 것이 제대로 작동하지만 푸시 알림이 iOS7 기기에서 더 이상 작동하지 않는 것으로 보입니다. 내가 빠진 것이 있습니까? 도와 줘서 고마워!iOS8은 푸시 알림을받을 수 있지만 iOS7은 수신 할 수 없습니다.

답변

1

사용

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { 
     [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound categories:nil]]; 
    } else { 
     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound]; 
    } 

     #ifdef __IPHONE_8_0 
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { 
    [application registerForRemoteNotifications]; 
} 
#endif 

그리고 다른 푸시 관련 방법이 ..이 두 IOS에서 작동이 코드 ..이 당신을 도울 것입니다

희망.

+0

감사합니다. 나 해보자. –

관련 문제