push not initilizing when trying to create hybrid android application

為{幸葍}努か 提交于 2019-12-24 17:20:02

问题


I am trying to implement push notifications using bluemix and mobilefirst. I have used the following links to implement

  1. http://www.ibm.com/developerworks/library/mo-cordova-push-app/
  2. http://mbaas-gettingstarted.ng.bluemix.net/hybrid#initialize-push -

When i run the the below code I am getting the following message in the console:

initPush called---------------- main.js:29 calling bluemix initialize with values---------------------- IBMBluemixHybrid.js:2956 [INFO] [DEFAULT] Hybrid initialize ["applicationid","applicationsecret","applicationroute"]

I neither see the device details reflected in the bluemix registered list. Can you please help me on this ?

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:


You need to replace "applicationId", "applicationRoute", and "applicationSecret" in the code

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

with those obtained from your Bluemix backend application.

From the bluemix dashboard for your application click mobile options in the top right to see your ID and Route.

For the secret navigate to the Mobile Application Security dashboard from the link on the right, and your secret will be displayed on that page.



来源:https://stackoverflow.com/questions/33281772/push-not-initilizing-when-trying-to-create-hybrid-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!