我之前使用以下代码在我的混合移动应用程序中实现推送。
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);
}
现在由于推送服务的变化,我正在实施推送通知,\
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
我通过创建一个cordova项目并向它们添加环境来获得这些.js(MFPush.js,BMSClient.js)文件。
我浏览了 blumix 文档,推送通知适用于 iOS、Android 和 Cordova 应用程序,但不适用于混合移动应用程序。
请在这方面提供帮助!
我没有在我的混合应用程序中使用适配器来初始化 Bluemix SDK。
我还检查了以下链接。