首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Unity解析推送无法使用iOS 9.1、Unity 4.6.9和Parse 1.6.1注册设备

Unity解析推送无法使用iOS 9.1、Unity 4.6.9和Parse 1.6.1注册设备
EN

Stack Overflow用户
提问于 2015-11-05 17:46:31
回答 1查看 232关注 0票数 1

我花了一天的时间尝试让推送通知与iOS应用的Parse Unity SDK协同工作。

我遵循了iOS推送通知教程:https://parse.com/tutorials/ios-push-notifications

我还使用了解析提供的推送通知快速入门应用程序:https://parse.com/apps/quickstart#parse_push/unity/ios/new

但设备仍然不会出现。

我已经搜索了这个论坛,但我找不到答案。

是的,我已经阅读了指南中提到的故障排除指南。

当我在我的手机上运行这个应用程序时,它确实会请求允许推送通知,所以它看起来有点起作用了。

但是Parse不会接收设备,所以我不能发送通知

但我制作的任何测试应用程序都不会注册这些应用程序。下面是我使用的代码:

代码语言:javascript
复制
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using Parse;
using System;

public class PushBehaviour : MonoBehaviour {
  // Use this for initialization
  void Awake() {
#if UNITY_IOS
    NotificationServices.RegisterForRemoteNotificationTypes(RemoteNotificationType.Alert |
                                                            RemoteNotificationType.Badge |
                                                            RemoteNotificationType.Sound);

    var installation = ParseInstallation.CurrentInstallation;
    installation.Channels = new List<string> { "ParseTest" };
    installation.SaveAsync();
#endif

    ParsePush.ParsePushNotificationReceived += (sender, args) => {
#if UNITY_ANDROID
      AndroidJavaClass parseUnityHelper = new AndroidJavaClass("com.parse.ParsePushUnityHelper");
      AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
      AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

      // Call default behavior.
      parseUnityHelper.CallStatic("handleParsePushNotificationReceived", currentActivity, args.StringPayload);
#elif UNITY_IOS
      IDictionary<string, object> payload = args.Payload;

      foreach (var key in payload.Keys) {
        Debug.Log("Payload: " + key + ": " + payload[key]);
      }
#endif
    };
  }
}

任何关于我哪里出错的反馈都将不胜感激。

谢谢您抽时间见我。

EN

回答 1

Stack Overflow用户

发布于 2016-01-05 18:03:31

不确定这是否能解决这个问题,但是

代码语言:javascript
复制
NotificationServices.RegisterForRemoteNotificationTypes is deprecated.

试着用这个代替。

代码语言:javascript
复制
UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33541213

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档