我早先正在使用以下代碼在混合移動應用程序中實施推送。如何在使用Bluemix的混合移動應用程序中實施推送通知
function EnablePushNotification(email)
{
var config = {
applicationId:'',
applicationRoute:'',
applicationSecret:''
//applicationSecret:''
};
console.log("EnablePushNotification : " + email);
return IBMBluemix.initialize(config)
.then(function() {
return IBMPush.initializeService();
})
.then(function(push1) {
var push = IBMPush.getService();
//device.model
//userName
push.registerDevice(email, email, "alertNotification")
.done(function(response) {
navigator.notification.alert("Device Registered : " + response);
console.log("Device Registered : " + response);
push.subscribeTag("SmarterSAM-Test").done(function(response) {
navigator.notification.alert("Device Subscribed : " + response);
console.log("Device Subscribed : " + response);
}, function(err){
navigator.notification.alert("Error in subscribe : " + err);
console.log("Error in subscribe : " + err);
});
}, function(err){
navigator.notification.alert("Error in Registering Device : " + err);
//console.log("Error in subscribe : " + err);
});
});
}
function alertNotification(message)
{
IBMBluemix.getLogger().info("Received notification");
navigator.notification.alert("Received notification : " + message);
}
現在由於在Push服務改變,我實現推送通知,\
function EnablePushNotification(email)
{
//deviceUserID = email;
console.log("--Inside EnablePushNotification--");
try {
//initialize SDK with IBM Bluemix application ID and route
//TODO: Please replace <APPLICATION_ROUTE> with a valid ApplicationRoute and <APPLICATION_ID> with a valid ApplicationId
debugger;
BMSClient.initialize("<APPLICATION_ROUTE>","<APPLICATION_ID>");
var success = function(message) { console.log("Success: " + message); };
var failure = function(message) { console.log("Error: " + message); };
MFPPush.registerDevice({}, success, failure);
this.registerNotificationsCallback();
}
catch (MalformedURLException) {
console.log("Error in initilization-->>" + MalformedURLException);
}
}
但我提示以下錯誤:。
啓動錯誤 - >> ReferenceError:BMSClient未定義。
在我的index.html,我已經包括MPUSH.js和BMSClient.js
我這些的.js(MFPush.js,BMSClient.js)文件創建一個科爾多瓦項目,並添加環境給他們。
我已經通過blumix文檔,推送通知是針對iOS,Android和Cordova應用程序給出的,但不適用於混合移動應用程序。
請幫忙在這方面!
我在混合應用程序中未使用適配器來初始化Bluemix SDK。
我也檢查了下面的鏈接。
您正在使用什麼版本的Mobile First Platform Foundation? –
嗨,戴夫!我正在使用MFP版本7。1 – user3719130