回答
@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. 設備註冊ID /設備令牌沒有生成
- 2. ios 7設備令牌對於同一設備不同
- 3. FCM令牌不是在一些Android設備中生成的
- 4. HLS與CDN令牌 - iOS設備
- 5. 新設備令牌的APNS證書iOS
- 6. 設備令牌沒有註冊ios 9
- 7. 令牌生成
- 8. 設備令牌NULL
- 9. Firebase令牌不生成
- 10. 設備令牌沒有在iOS 10上爲XCode 7.3構建的應用生成
- 11. Firebase - iOS設備上設備上的無效令牌
- 12. 的iOS registerForRemoteNotifications不會產生錯誤,但不火的委託,讓設備令牌
- 13. APNS會每次爲單個設備生成新的設備令牌嗎?
- 14. 未設置設備令牌
- 15. 我的應用程序無法生成設備令牌
- 16. 設備令牌生成和拋撒推送通知
- 17. 如何生成用於Apple推送通知的設備令牌?
- 18. 生成LTPA令牌?
- 19. CSRF令牌生成
- 20. Flask令牌生成
- 21. 將SQL令牌生成器更改爲Java令牌生成器
- 22. 未收到設備令牌
- 23. Apple APNS設備令牌
- 24. 請求設備令牌
- 25. APNS - 獲取設備令牌
- 26. MDM設備令牌問題
- 27. 獲取設備令牌?
- 28. 獲取Android設備令牌
- 29. 如何在iOS數據庫上存儲iOS設備令牌?
- 30. apns離子不好設備令牌
有時會有效,有時不會:在同一臺設備上?各種設備?各種iOS版本?錯誤回調是否被調用? – Larme
我不認爲這是一個很好的做法,兩次問同一件事。在你的兩個問題中,你沒有提供任何細節,代碼,iOS版本等,你沒有顯示任何研究工作。我強烈建議您刪除其中一個問題,並在您保留的問題中儘可能包含有關該問題的詳細信息。乾杯! –