【发布时间】:2017-07-05 12:30:25
【问题描述】:
我正在 Unity 中开发 iOS 应用程序。我需要显示本地推送通知。
我使用下一个代码:
public class TestNotification : MonoBehaviour {
void Start(){
UnityEngine.iOS.NotificationServices.RegisterForNotifications(UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound);
}
public void ShowNotification(){
#if UNITY_IOS
var iOSNotification = new UnityEngine.iOS.LocalNotification();
iOSNotification.alertBody = "Hello!";
UnityEngine.iOS.NotificationServices.PresentLocalNotificationNow(iOSNotification);
#else
Debug.LogError("Platform is not supported.");
#endif
}
}
当我调用 ShowNotification 时,通知会出现在通知面板中,但没有任何声音和弹出窗口。如何让我的通知正常显示?我在发布时接受了所有权限(警报、声音、徽章)。
测试设备:iPhone 4s、iOS 9.3.5
构建:Unity 5.4.4f1、XCode 8.2.1
【问题讨论】: