【问题标题】:Parse Push Notifications Testing PFInstallation Not Working解析推送通知测试 PFInstallation 不工作
【发布时间】:2016-01-11 17:20:59
【问题描述】:

我是一名客观的 c 程序员,尝试在解析中使用推送通知。

我在 appDelegate.m 文件的 didFinishLaunchingWithOptions 部分添加了 Parse setApplicationID 和 Client Key。然后我添加了这两个方法:

- (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.badge = 0;
NSArray *channels = [NSArray arrayWithObjects:@"global", [DataSource sharedInstance].userProfile.userID, nil];
[currentInstallation addObjectsFromArray:channels forKey:@"channels"];
[currentInstallation saveInBackground];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}

每当 currentInstallation.badge 编号发生变化时,应用程序上的徽章编号都会响应,当我断点代码时,它表明频道已添加到 currentInstallation。

问题在于当前安装未保存在 Parse 数据库的核心安装对象部分中。我添加到 currentInstallation 的频道在 saveInBackground 运行后没有出现。

在调试问题时,我删除了核心安装数据库中与我用于测试的设备相对应的行(这是核心安装数据库中的唯一对象)。当我重新运行代码时,什么都没有添加。

还有一条信息是,我很确定我正确地完成了所有设置,因为在设置完所有内容后,我能够在我的设备上接收测试推送通知。问题是我无法以编程方式更改我的测试设备在核心安装数据库上订阅的频道。

所以基本上我的问题是:如何使用 PFInstallation saveInBackground 将项目写入核心安装数据库?我做错了什么?

感谢您的帮助!我真的很感激!

编辑 现在,另一个问题是我无法将我正在测试推送通知的设备添加回我的核心安装对象数据库,所以我仍然在数据库中的 0 个对象。关于如何找回它的任何建议?

【问题讨论】:

  • 试试PFPush subscribeToChannelInBackground:。您可能还需要删除该应用并重新安装它
  • @Wain 删除应用程序并重新安装是什么意思?在 Parse 中删除它?
  • @Wain 感谢您的帮助,但这些都不起作用!还有其他建议吗?
  • 这是唯一不起作用的东西吗?没有立即想到其他想法......
  • @Wain 我也添加了这个问题:stackoverflow.com/questions/34728888/… 这是我唯一认为可能是错误的。再次感谢您的帮助

标签: ios objective-c parse-platform push-notification pfinstallation


【解决方案1】:

这太令人沮丧了。我所要做的就是注销我的 Parse 帐户,然后重新登录。瞧!频道就在那里!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-17
    相关资源
    最近更新 更多