【发布时间】:2015-11-08 17:22:43
【问题描述】:
我目前正在向我的 Parse 应用程序添加推送通知,并且需要使用 PFInstallation 注册每个设备才能这样做。我的应用程序已成功注册推送通知,当我第一次启动它时,它询问我是否想在设备上接收推送通知。第一次启动时,我在相应的AppDelegate.m方法中运行代码,如下:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(@"Registered");
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = @[ @"global" ];
[currentInstallation saveInBackground];
}
这应该已经使用PFInstallation 将我的设备保存到 Parse。但是,当我访问 Parse.com 并转到 Push 选项卡并查看“Audiences”下时,没有注册任何设备。我认为这可能是因为我的一些分发和开发证书,以及我的配置文件已经过时了。所以我更新了这些,并运行了另一段类似的代码来尝试保存PFInstallation:
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.channels = @[ @"global" ];
[currentInstallation saveInBackground];
我在我的应用程序的 viewDidLoad 方法中运行了它,因为 AppDelegate.m 方法只会运行一次。但是,在我的 Parse 控制台中仍然没有看到 PFInstallation。
为什么PFInstallation 没有被注册?我该如何解决这个问题?
感谢所有帮助。
【问题讨论】:
标签: ios objective-c iphone parse-platform ios9