Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

NotificationServices.RegisterForNotifications

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public static function RegisterForNotifications(notificationTypes: iOS.NotificationType): void;
public static void RegisterForNotifications(iOS.NotificationType notificationTypes);
public static function RegisterForNotifications(notificationTypes: iOS.NotificationType, registerForRemote: bool): void;
public static void RegisterForNotifications(iOS.NotificationType notificationTypes, bool registerForRemote);

パラメーター

notificationTypes 登録する通知タイプ
registerForRemote リモート通知を登録する場合は true

説明

Apple のプッシュ通知サービスを経由して、指定したローカルまたはリモート通知タイプの受信を登録します。

指定のリモート通知のタイプをアプリケーションに登録した後、デバイストークンを受け取り、NotificationServices.deviceToken 経由で利用することができます。

#pragma strict

public class NotificationRegistrationExample { var tokenSent;

function Start() { tokenSent = false; iOS.NotificationServices.RegisterForNotifications( iOS.NotificationType.Alert | iOS.NotificationType.Badge | iOS.NotificationType.Sound); }

function Update() { if (!tokenSent) { var token = iOS.NotificationServices.deviceToken; if (token != null) { // send token to a provider var hexToken = "%" + System.BitConverter.ToString(token).Replace('-', '%'); new WWW("http:/example.com?token=" + hexToken); tokenSent = true; } } } }
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; } } } }