gpt4 book ai didi

ios - Unity Parse Push 无法使用 iOS 9.1、Unity 4.6.9 和 Parse 1.6.1 注册设备

转载 作者:行者123 更新时间:2023-11-29 12:10:37 25 4
gpt4 key购买 nike

我花了一天时间尝试获取推送通知,以便与适用于 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
};
}
}

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

感谢您的宝贵时间。

最佳答案

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

NotificationServices.RegisterForRemoteNotificationTypes is deprecated.

尝试改用它。

UnityEngine.iOS.NotificationServices.RegisterForNotifications (UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound);

关于ios - Unity Parse Push 无法使用 iOS 9.1、Unity 4.6.9 和 Parse 1.6.1 注册设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33541213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com