1

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);
           }); 
ralphearle
  • 1,696
  • 13
  • 18

1 Answers1

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.

enter image description here enter image description here

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. enter image description here

James Young IBM
  • 616
  • 1
  • 5
  • 13
  • Thanks for quick reply. I did set the values that you shared. I did not want to share the details so I replaced with "applicationId", "applicationRoute", and "applicationSecret". It did not work even then. I dont see it either going to success or failure callback . – Sharan Ainapurapu Oct 26 '15 at 11:15
  • I have opened up condova.js file inside the project. I saw something called var PLATFORM_VERSION_BUILD_LABEL = '3.6.4'. I am guessing that this the version of cordova. Correct me if I am wrong. I am using mobilefirst 7.1. Might be these numbers can give you some clue. Let me know if you want some more information – Sharan Ainapurapu Oct 26 '15 at 11:20
  • You can check the version of Cordova from your terminal by running `cordova -v`, if you used NPM to install Cordova initially you can downgrade to 4.3 by uninstalling Cordova with `npm -g uninstall cordova` and then reinstalling 4.3 with `npm -g install cordova@4.3.0` – James Young IBM Oct 26 '15 at 13:23
  • It is does not necessarily mean that the version of cordova installed in my laptop must be equal to the one in the MF project right? By doing the process you mentioned, will it effect the MF as well ? – Sharan Ainapurapu Oct 26 '15 at 13:37
  • The PLATFORM_VERSION_BUILD_LABEL you referenced is just the platform (ios, android, web) cordova build version and is not related to the CLI/lib version which the above is having you modify to 4.3. I do not believe this will affect your MF, if it does then simply undo the process and reinstall cordova without the @4.3.0 specification. – James Young IBM Oct 26 '15 at 13:47