回答
@GopalDevra你能更清楚吗?无论如何,我有这个代码解析,也许这不是你的情况,但你可以明白。
可以在AppDelegate.m使用didRegisterForRemoteNotificationsWithDeviceToken像:
- (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];
}
编辑
你把这个在didFinishLaunchingWithOptions?
// - Push notifications
// -- Register for Push Notitications
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
//-- Set Notification
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:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
//--- your custom code
非常感谢 我试过这些代码行。 但不工作 –
@GopalDevra我更新了我的答案。一探究竟。 –
@ J.Lopes您今天能够从沙箱APN获取设备令牌吗? –
你把下面的AppDelegate.m
didFinishLaunchingWithOptions
?
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
NSLog(@"ios8 app");
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
NSLog(@"lower ios8 app");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
}
添加这种方法,
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError)
{
print("application:didFailToRegisterForRemoteNotificationsWithError: %@", error)
}
你会得到答案,也不会产生为什么令牌。
Edit for objective c :-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { } –
截至目前,我也无法获得设备令牌。
我的项目在10小时前“擦除”和“安装”时停止生成设备令牌。 也在韩国iOS开发者论坛上,有些人一直在报告过去10个小时内没有生成APNS令牌的问题。
某些沙箱APNS服务器可能有问题。
- 最后检查时间 2016年4月27日22:43 PM 0900 GMT:没有设备令牌,推送通知没有到达。
这是真的发生了@CheeseLemon? –
是的,现在每个人都在报告它现在正在工作。 – CheeseLemon
- 1. FCM令牌不是在一些Android设备中生成的
- 2. 新设备令牌的APNS证书iOS
- 3. 设备令牌没有注册ios 9
- 4. HLS与CDN令牌 - iOS设备
- 5. 设备令牌没有在iOS 10上为XCode 7.3构建的应用生成
- 6. 设备令牌NULL
- 7. Firebase令牌不生成
- 8. 未设置设备令牌
- 9. 如何生成用于Apple推送通知的设备令牌?
- 10. 我的应用程序无法生成设备令牌
- 11. 生成LTPA令牌?
- 12. Flask令牌生成
- 13. CSRF令牌生成
- 14. 将SQL令牌生成器更改为Java令牌生成器
- 15. 如何在iOS数据库上存储iOS设备令牌?
- 16. 获取Android设备令牌
- 17. Apple APNS设备令牌
- 18. 未收到设备令牌
- 19. apns离子不好设备令牌
- 20. APNS设备令牌不符合生产证书
- 21. Elasticsearch不生成数字令牌
- 22. Django 1.11不生成CSRF令牌
- 23. 如何生成oauth令牌?
- 24. 生成JSON Web令牌
- 25. ASP.NET身份 - 生成令牌
- 26. ejabberd否认生成令牌
- 27. 令牌生成和表达
- 28. 设备令牌从一个设备到另一个设备是不同的
- 29. 没有得到iPhone iOS 5.1的设备令牌Xcode 4.3.1
- 30. Pushsharp 4.0.10.0 iOS设备令牌的ApnsConfiguration连接错误
有时会有效,有时不会:在同一台设备上?各种设备?各种iOS版本?错误回调是否被调用? – Larme
我不认为这是一个很好的做法,两次问同一件事。在你的两个问题中,你没有提供任何细节,代码,iOS版本等,你没有显示任何研究工作。我强烈建议您删除其中一个问题,并在您保留的问题中尽可能包含有关该问题的详细信息。干杯! –