我按照这些步骤进行推送通知,但无法接收推送设备。
步骤
代码:
Array
(
[0] => Array
(
[email] => abc@gmail.com
[id] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
)
答案 0 :(得分:0)
注册用户通知设置后,您需要通过调用此方法[[UIApplication sharedApplication] registerForRemoteNotifications]
来注册远程通知。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//ios 9
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings =
[UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
//call this method here
[[UIApplication sharedApplication] registerForRemoteNotifications];
return YES;
}
答案 1 :(得分:0)
在AppDelegate.m的didFinishLaunchingWithOptions中添加以下代码:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
为我的iOS 9.0和Xcode 7.2工作。