尝试创建混合Android应用程序时不要启动

时间:2015-10-22 13:06:22

标签: push-notification cordova-plugins ibm-cloud ibm-mobilefirst ibm-cloud-plugin

我正在尝试使用bluemix和mobilefirst实现推送通知。我使用以下链接来实现

  1. http://www.ibm.com/developerworks/library/mo-cordova-push-app/
  2. http://mbaas-gettingstarted.ng.bluemix.net/hybrid#initialize-push -
  3. 当我运行以下代码时,我在控制台中收到以下消息:

      

    initPush调用----------------   main.js:29调用bluemix初始化值----------------------   IBMBluemixHybrid.js:2956 [INFO] [DEFAULT]混合初始化[" applicationid"," applicationsecret"," applicationroute"]

    我既没有看到bluemix注册列表中反映的设备详细信息。你能帮帮我吗?

    var values = {
                applicationId:"applicationId",
                applicationRoute:"applicationRoute",
                applicationSecret:"applicationSecret"
            };
            console.log("initPush called---------------------------------");           
               console.log("calling bluemix initialize with values--------------------------------");
    
               IBMBluemix.initialize(values).then(function(status) {
                  console.log("IBM Bluemix Initialized", status);
                  return IBMPush.initializeService();
               }, function (err) {
                  console.error("IBM Bluemix initialized failed" , err);
               }).then(function(pushObj) {
                      function pushReceived(info) {
                           console.log("registerListener - " + info.alert);
                           alert('got a push message! ' + info.alert);
                      }
                  console.log("IBM Push Initialized", pushObj);
                  push = pushObj;
                  return push.registerDevice("LisaTest","Lisa123","pushReceived");
               }, function (err) {
                  console.error("IBM Bluemix Push initialized failed" , err);
               }); 
    

1 个答案:

答案 0 :(得分:1)

您需要在代码中替换“applicationId”,“applicationRoute”和“applicationSecret”

var values = {
        applicationId:"applicationId",
        applicationRoute:"applicationRoute",
        applicationSecret:"applicationSecret"
    };

从您的Bluemix后端应用程序获得的那些。

在应用程序的bluemix仪表板中,单击右上角的移动选项以查看您的ID和路线。

enter image description here enter image description here

对于秘密,从右侧的链接导航到Mobile Application Security仪表板,您的秘密将显示在该页面上。 enter image description here