notificationTypes | 登録する通知タイプ |
registerForRemote | リモート通知を登録する場合は true |
Apple のプッシュ通知サービスを経由して、指定したローカルやリモート通知タイプの受信を登録します
指定のリモート通知のタイプをアプリケーションに登録した後、デバイストークンを受け取り、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; } } } }