Cordova での SMS 通知の処理
improve this page | report issue概説
SMS 通知は、プッシュ通知のサブセットです。したがって、最初に、Cordova でのプッシュ通知チュートリアルを必ずお読みください。
Cordova アプリケーションでの SMS 通知は、iOS および Android を対象にサポートされます。
前提条件
- 必ず、以下のチュートリアルをお読みください。
- ローカルで稼働している MobileFirst Server、またはリモートで稼働している MobileFirst Server
- 開発者ワークステーションに MobileFirst CLI がインストールされていること
ジャンプ先:
通知 API
SMS 通知では、デバイスを登録するときに電話番号値が渡されます。
デバイスの登録
デバイスをプッシュ通知サービスに登録します。
MFPPush.registerNotificationsCallback(notificationReceived);
function registerDevice() {
var phoneNumber = prompt("Enter Your 10 digit phone number");
if(phoneNumber != null && phoneNumber!="" && /^\d+$/.test(phoneNumber)) {
var options = {};
options.phoneNumber = phoneNumber;
MFPPush.registerDevice(options,
function(successResponse) {
alert("Successfully registered");
enableButtons();
}, function(failureResponse) {
alert("Failed to register");
});
return true;
}
else {
alert("Failed to register, You have entered invalid number");
}
}
プッシュ・デバイス登録 (POST) REST API を使用してデバイスを登録することもできます。
SMS サブスクライブ・サーブレットの使用
登録済みデバイスに通知を送信するときは REST API が使用されます。 すべての形式の通知 (タグ通知、ブロードキャスト通知、および認証済み通知) を送信できます。
通知を送信するために、POST を使用して REST エンドポイントへの要求が行われます (imfpush/v1/apps/<application-identifier>/messages
)。
URL の例を以下に示します。
https://myserver.com:443/imfpush/v1/apps/com.sample.sms/messages
すべてのプッシュ通知 REST API を確認するには、ユーザー資料の REST API ランタイム・サービスのトピックを参照してください。
通知を送信するには、通知の送信チュートリアルを参照してください。
サンプル・アプリケーション
ここをクリック して Cordova プロジェクトをダウンロードします。
注: サンプルを実行するには、Android デバイス上に最新バージョンの Google Play Services がインストールされている必要があります。
サンプルの使用法
サンプルの README.md ファイルの指示に従ってください。
▲Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on February 28, 2020