后端 - Django
前端 - objective-c (X 代码)
我关注了this Apple Document 配置推送通知并成功完成所有步骤。
对于后端,我使用 django-push-notifications使用Django==1.7,发送消息时不会出错。
对于前端,我添加了以下几行来接收通知,
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
- (void)applicationUIApplication *)application didRegisterForRemoteNotificationsWithDeviceTokenNSData *)deviceToken
{
NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString"<>"]];
token = [token stringByReplacingOccurrencesOfString" " withString""];
NSLog(@"content---%@", token);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle"DeviceToken!!!" message:token delegate:self cancelButtonTitle"Cancel" otherButtonTitles:nil];
[alert show];
}
- (void)applicationUIApplication *)application didReceiveRemoteNotificationNSDictionary *)userInfo {
....
}
但在此之后,我无法收到通知。我是否正确完成并配置了步骤?我的 X 代码版本是 6.3,苹果设备的 iOS 版本是 8.4。两者都应该是兼容的版本来接收通知吗?
有没有办法在 APNs 云上记录或查看进度?
使用deviceToken直接点赞
- (void)applicationUIApplication*)application didRegisterForRemoteNotificationsWithDeviceTokenNSData*)deviceToken {
NSLog(@"My token is: %@", deviceToken);
}
您还需要确保发送推送通知。
尝试使用 this tutorial以及他们的应用程序,它将帮助您确保正确发送 Push 并且您需要修复前端。
关于未收到 iOS 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31176955/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |