【问题标题】:Google Play Services iOS 's push notifications is not workingGoogle Play Services iOS 的推送通知不起作用
【发布时间】:2016-12-23 20:01:32
【问题描述】:

我正在使用来自https://github.com/playgameservices/ios-basic-samples 的 TBMPSkeleton 在 iOS 中测试 Google Play 服务

我确实在 Google Play 控制台 (link) 中上传了所有 APNS 证书,但在设备上运行游戏时,在开发或生产环境中收到邀请或比赛状态发生变化时,我没有收到任何通知。调试显示游戏确实成功接收了 APNS 令牌,我确实使用来自 https://www.raywenderlich.com/123862/push-notifications-tutorial 的 php 脚本测试了我的证书并成功发送了推送通知。

那么我的项目有什么问题?我配置错了吗?我正在使用 XCode 7.3.1 (7D1014)、Google Play 服务 5.1.1

【问题讨论】:

    标签: ios google-play-services


    【解决方案1】:

    检查Adding Push Notifications in Your iOS Game

    很高兴您能够下载您的 APNS 证书。但这只是第一步。接下来的步骤是:

    第 2 步。创建包含推送通知权利的配置文件。要了解如何创建配置文件,您可以参考 Apple Developer Provisioning and Development 文档,在“创建和安装配置文件”下。确保将配置文件拖到管理器中的测试设备。

    第 3 步。将您创建的 .p12 文件上传到 Google Play 开发者控制台。 .p12 文件必须是 PKCS #12 格式,并且必须只包含一个证书。

    第 4 步:注册您的应用以在用户成功登录后接收推送通知。在您的finishedWithAuth:error 处理程序中添加以下代码,此时用户已成功登录到Google Play 游戏服务。这会打开标准的 iOS 推送通知对话框。如果您的游戏已经通过在别处实现此代码注册了推送通知,那么您无需再次添加此行。

    [[UIApplication sharedApplication] registerForRemoteNotifications:
    (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];
    

    第 5 步。在您的 appDelegate 中,将以下代码添加到回调中,以检索从 APNS 传回的推送设备令牌。此设备令牌用于出站推送通知,您的应用必须将其注册到 Google Play 游戏服务推送服务。确保始终通过 GPGManager 注册您的设备令牌,以启用来自 Google Play 游戏服务的推送通知。即使用户尚未登录; GPGmanager 对象将缓存此令牌并保存直到用户登录。

    - (void)application:(UIApplication *)application
            didRegisterForRemoteNotificationsWithDeviceToken
            :(NSData *)deviceToken {
        NSLog(@"Got deviceToken from APNS! %@", deviceToken);
        [[GPGManager sharedInstance] registerDeviceToken:deviceToken
                forEnvironment:GPGPushNotificationEnvironmentSandbox];
    }
    

    【讨论】:

    • 感谢您的回答。是的,我确实遵循了此文档并成功接收了设备令牌,但我收不到任何通知。你有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 2023-03-17
    • 1970-01-01
    相关资源
    最近更新 更多