我在iOS应用中实现了推送通知。它在iOS 8.0(in iPhone 5s)
和iOS 7.1.1(in iPhone 5)
中工作正常,但无法在iOS 7.0.2(in iPhone 4s)
中使用。
以下是代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
// iOS < 8 Notifications
[application registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
UIViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"idHome"];
navController = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
}
我甚至得到所有版本的device token id
。
让我知道我哪里出错了。我该如何解决这个问题?