notificationTypes | 要注册的通知类型。 |
registerForRemote | 指定 true 还将注册远程通知。 |
注册以通过 Apple Push Service 从提供程序接收指定类型的本地和远程通知。
在应用程序注册指定的远程通知类型后,将从 Apple Push Service 接收设备令牌,并可通过 NotificationServices.deviceToken 获取。
using UnityEngine; using System.Collections; using NotificationServices = UnityEngine.iOS.NotificationServices; using NotificationType = UnityEngine.iOS.NotificationType;
public class NotificationRegistrationExample : MonoBehaviour { bool tokenSent;
void Start() { tokenSent = false;
NotificationServices.RegisterForNotifications( NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); }
void Update() { if (!tokenSent) { byte[] token = NotificationServices.deviceToken; if (token != null) { // send token to a provider string hexToken = "%" + System.BitConverter.ToString(token).Replace('-', '%'); new WWW("http:/example.com
?token=" + hexToken); tokenSent = true; } } } }