私はCordovaアプリ(Telerik Appbuilderを使用)とこのAzure Mobile Servicesプラグイン(https://github.com/Azure/azure-mobile-apps-cordova-client)を使用してプッシュ通知に登録しています。私はPNS(gcmとapns)から正常に応答し、Notificationハブで登録(登録イベント)を呼び出すと、以下の正常な応答が返されます。タグを指定せずにAzure通知ハブから「テスト送信」ユーティリティを使用して通知を送信すると、デバイス上の通知(IOSとAndroidの両方)も取得されますが、タグを使用して通知を送信しようとすると通知は受信されません。タグを登録するには?タグが動作しないプッシュ通知の登録
`pushRegistration.on('registration', function (data) {
var client = new WindowsAzure.MobileServiceClient(
"http://xxxxxx.azurewebsites.net"
);
// Get the native platform of the device.
var platform = device.platform;
// Get the handle returned during registration.
var handle = data.registrationId;
// Set the device-specific message template.
if (platform == 'android' || platform == 'Android') {
client.push.register('gcm', handle, {
mytemplate: { body: { data: { message: "{$(messageParam)}" } },
tags: ["mynotificationtag", "anothertag"]}
}).then(function(data){
alert("success");
},function(error){
alert(error);
});
} else if (device.platform === 'iOS') {
// Register for notifications.
client.push.register('apns', handle, {
mytemplate: { body: { aps: { alert: "{$(messageParam)}" } },
tags: ["mynotificationtag", "anothertag"]}
}).then(function(data){
alert("success");
},function(error){
alert(error);
});
} else if (device.platform === 'windows') {
// Register for WNS notifications.
client.push.register('wns', handle, {
myTemplate: {
body: '<toast><visual><binding template="ToastText01"><text id="1">$(messageParam)</text></binding></visual></toast>',
headers: { 'X-WNS-Type': 'wns/toast' } }
});
}
});`
MobileServices.Cordova.jsでプラグインの「登録」メソッドは、我々はテンプレートオブジェクトのプロパティとしてのタグを指定する必要があります言う
- 下記を参照してください:
`/// <summary>
/// Register a push channel with the Mobile Apps backend to start receiving notifications.
/// </summary>
/// <param name="platform" type="string">
/// The device platform being used - wns, gcm or apns.
/// </param>
/// <param name="pushChannel" type="string">
/// The push channel identifier or URI.
/// </param>
/// <param name="templates" type="string">
/// An object containing template definitions. **_Template objects should contain body, headers and tags properties._**
/// </param>
/// <param name="secondaryTiles" type="string">
/// An object containing template definitions to be used with secondary tiles when using WNS.
/// </param>
Push.prototype.register = Platform.async(
function (platform, pushChannel, templates, secondaryTiles, callback) {
Validate.isString(platform, 'platform');
Validate.notNullOrEmpty(platform, 'platform');
// in order to support the older callback style completion, we need to check optional parameters
if (_.isNull(callback) && (typeof templates === 'function')) {
callback = templates;
templates = null;
}
if (_.isNull(callback) && (typeof secondaryTiles === 'function')) {
callback = secondaryTiles;
secondaryTiles = null;
}
var requestContent = {
installationId: this.installationId,
pushChannel: pushChannel,
platform: platform,
templates: stringifyTemplateBodies(templates),
secondaryTiles: stringifyTemplateBodies(secondaryTiles)
};
executeRequest(this.client, 'PUT', pushChannel, requestContent, this.installationId, callback);
}
);`