我花了一天的时间尝试使用推送通知来使用适用于iOS应用的Parse Unity SDK。
我按照iOS推送通知教程:https://parse.com/tutorials/ios-push-notifications
我还使用了Parse推送通知提供的快速入门应用程序: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
};
}
}
对于我出错的地方的任何反馈都将受到高度赞赏。
感谢您的时间。
答案 0 :(得分:1)
不确定这是否会解决,但
NotificationServices.RegisterForRemoteNotificationTypes is deprecated.
请尝试使用此功能。
UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound);