2014-11-17 3 views
0

이것은 매우 이상합니다. 나는 6 개의 앱을 가지고 있는데 모두 똑같은 코드를 공유하고있다. 지금은 내 iPhone 4를 사용하여 완벽하게 작동한다. iPhone 6 + 8.1 버전에서 모든 앱을 다운로드 했으므로 6 개의 앱 중 4 개가 푸시 알림으로 작동하지 않습니다. 놀랍게도 앱 위임자의 코드는 모두 정확합니다.구문 분석 푸시 알림이 IOS에서 올바르게 작동하지 않습니다. 8.1

원격 알림 8 등록은 약간 변경되었습니다 아이폰 OS에서
- (BOOL)   application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // xxx = for security reasons 
    [Parse setApplicationId:@"XXXXX" clientKey:@"XXXXX"]; 

    // more parse setting 
    [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge| 
                UIRemoteNotificationTypeAlert| 
                UIRemoteNotificationTypeSound)]; 

    if (application.applicationState != UIApplicationStateBackground) { 
    // Track an app open here if we launch with a push, unless 
    // "content_available" was used to trigger a background push (introduced 
    // in iOS 7). In that case, we skip tracking here to avoid double 
    // counting the app-open. 
    BOOL preBackgroundPush = ![application respondsToSelector:@selector(backgroundRefreshStatus)]; 
    BOOL oldPushHandlerOnly = ![self respondsToSelector:@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)]; 
    BOOL noPushPayload = ![launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 
    if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) { 
     [PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions]; 
    } 

    //reset my badge of parse.com notification 
    PFInstallation *currentInstallation = [PFInstallation currentInstallation]; 
    if (currentInstallation.badge != 0) { 
     currentInstallation.badge = 0; 
     [currentInstallation saveEventually]; 
    } 
    return YES; 
} 

- (void)        application:(UIApplication *)application 
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 
{ 
    // Store the deviceToken in the current installation and save it to Parse. 
    PFInstallation *currentInstallation = [PFInstallation currentInstallation]; 
    [currentInstallation setDeviceTokenFromData:deviceToken]; 
    [currentInstallation saveInBackground];     
} 

//parse setting 
- (void)   application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 
    if (application.applicationState == UIApplicationStateInactive) { 
     // The application was just brought from the background to the foreground, 
     // so we consider the app as having been "opened by a push notification." 
     [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; 

     //reset my badge of parse.com notification 
     PFInstallation *currentInstallation = [PFInstallation currentInstallation]; 
     if (currentInstallation.badge != 0) { 
      currentInstallation.badge = 0; 
      [currentInstallation saveEventually]; 
     } 
    } 
} 

// parse anylitics 
- (void)   application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
     fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 
{ 
    if (application.applicationState == UIApplicationStateInactive) { 
     [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; 
    } 
} 
+0

작동하지 않는 것에 대해 좀 더 구체적으로 설명해 주시겠습니까? 장치가 밀어 넣기 알림을 등록하지 않거나 단순히 알림을받지 못하는 경우 모두 유효한 DeviceToken이있는 경우 설치 테이블을 확인 했습니까? –

+0

빠른 답장을 보내 주셔서 감사합니다. 나는 언급을 잊어 버렸고, 장치는 푸시 등록을하지 않았다. – XcodeNOOB

답변

0

:

아이폰 OS 8 일
if application.respondsToSelector("registerUserNotificationSettings:") { 
     let userNotificationTypes = UIUserNotificationType.Alert | .Badge | .Sound 
     let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil) 
     application.registerUserNotificationSettings(settings) 
     application.registerForRemoteNotifications() 
    } else { 
     let types = UIRemoteNotificationType.Badge | .Alert | .Sound 
     application.registerForRemoteNotificationTypes(types) 
    } 

이 추가 된 새로운 방법 'registerUserNotificationSettings은'시도

이 푸시 알림에 대한 내 코드입니다 로컬 및 원격 알림 모두에 가능한 알림 유형을 등록합니다.

P. Swift에서 제공되는 샘플이지만 Objective-C로 쉽게 변환 할 수 있습니다.

관련 문제