我正在处理推送通知.我编写了以下代码来获取设备令牌.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
NSLog(@"Registering for push notifications...");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
return YES;
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(@"This is device token%@", deviceToken);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"Error %@",err);
}
Run Code Online (Sandbox Code Playgroud)
我能够在设备上成功运行应用程序,但无法在控制台上获取设备ID.
我对认证和配置文件没有任何问题.
iphone push-notification apple-push-notifications ios appdelegate
我正在尝试amazon sns从控制台中创建平台终结点。以下是我从中收到的设备令牌FCM/APNs:
fUG5dIcN_pA:APA91bEciRwWuvTIezAKcJ5y1xz5z6BygE3YJkywdCGCFJD93NTfjARwPRommwgsfvVo2iH_qZWT7D2Lxnc69uanato1UUq-nLl5R1L0qF4exT7zjM9Wdy9Evs6h-EOBtIVv7Vv8bPE1
我收到一个错误消息:iOS设备令牌必须不超过400个十六进制字符。看起来APNs已以字符串格式发送令牌,而Amazon期望以十六进制字符形式发送。