按照文档中的说明,上传了p12文件,添加了下列函数在appDelegate中,
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
// Register for push notifications
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
...
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
AVInstallation *currentInstallation = [AVInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
但是在avos后台看不到installation增加?也收不到推送消息,我的实现有什么问题么?
有几个地方需要检查一下:
1,你启动的时候操作系统询问你对Push Notification进行授权了没有?可以在设置->通知中心->包括 中进行确认:如果没有开启通知,请在这里开启;如果都没有看到你的app,那么你的签名证书或者app Id设置还不对,请到developer.apple.com修改;
2,上一步没有问题,那么请确认一下p12是development证书还是distribution证书?
3,如果设置都没有问题,那么请在
(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
函数中设置断点,看看具体的错误信息是什么。4,注意一点,对于iOS来讲,_Notification表中installationid永远是空的(这一列对Android设备有效),devicetoken是有数据的。
详细情况可以参考这篇博客: https://blog.avoscloud.com/1163/