我花了一天的时间尝试让推送通知与iOS应用的Parse Unity SDK协同工作。
我遵循了iOS推送通知教程:https://parse.com/tutorials/ios-push-notifications
我还使用了解析提供的推送通知快速入门应用程序:https://parse.com/apps/quickstart#parse_push/unity/ios/new
但设备仍然不会出现。
我已经搜索了这个论坛,但我找不到答案。
是的,我已经阅读了指南中提到的故障排除指南。
当我在我的手机上运行这个应用程序时,它确实会请求允许推送通知,所以它看起来有点起作用了。
但是Parse不会接收设备,所以我不能发送通知
但我制作的任何测试应用程序都不会注册这些应用程序。下面是我使用的代码:
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
};
}
}任何关于我哪里出错的反馈都将不胜感激。
谢谢您抽时间见我。
发布于 2016-01-05 18:03:31
不确定这是否能解决这个问题,但是
NotificationServices.RegisterForRemoteNotificationTypes is deprecated.试着用这个代替。
UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound);https://stackoverflow.com/questions/33541213
复制相似问题