Push notifications are not working in iOS 9

前端 未结 5 598
死守一世寂寞
死守一世寂寞 2020-12-31 06:36

I have upgraded my devices to iOS 9 and my Xcode environment to 7.0 beta. Push notifications are not working in iOS 9?

Here is my code:

  float ver =         


        
5条回答
  •  萌比男神i
    2020-12-31 06:58

    write this code in didFinishLaunchingWithOptions

     UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                    UIUserNotificationTypeBadge |
                                                    UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                             categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];
    

    and add this method to AppDelegate as i have used for parse push notification service

     - (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.channels = @[ @"global" ];
    [currentInstallation saveInBackground];
    }
    

提交回复
热议问题