Search code examples
push-notificationibm-mobilefirst

IBM Mobile First Push Notification not working for Hybrid application


I'm having an issue receiving push notifications on android devices

Steps I followed:

  1. Created an app with all security configuration
  2. Created an adapter for submitting notification
  3. Built and deployed the application and adapter
  4. Opened the app in my device (android) and subscribed for the Push Notification

    a. Used form authentication (using j_security_check)

    b. Provided a mobile number as username

  5. Invoked the adapter's submit notification function.

    a. Got response saying the Push Notification is sent to the user

But no Push Notification appearing on device (android). Tried on couple of devices (android), but having same issue.

How can I debug the issue or what am I doing wrong here.

P.S I have the sample Push application working fine. But on integration with my application it's not working. Only the difference is the login page

Sample Push App login page

<form id="loginForm" >
  <input type="text" id="usernameInputField" placeholder="Username"/><br />
  <input type="password" id="passwordInputField" placeholder="Password"/><br/>      
  <input type="button" id="loginButton" value="Login" />
</form>

Button Bind Code

$('#loginButton').bind('click', function () {
  var reqURL = '/j_security_check';
  var options = {};
  options.parameters = {
    j_username : $('#usernameInputField').val(),
    j_password : $('#passwordInputField').val()
  };
  options.headers = {};

  pushAppRealmChallengeHandler.submitLoginForm(reqURL, options, pushAppRealmChallengeHandler.submitLoginFormCallback);
});

My App login page

<span class="fields">
  <input type="text" data-role="none" placeholder="Mobile Number" class="input_text" id="mobnum"/>
  <input type="text" data-role="none" placeholder="Name" class="input_text" id="name"/>
  <input type="text" data-role="none" placeholder="Email ID" class="input_text" id="email"/>
  <input type="text" data-role="none" placeholder="Organization" class="input_text" id="org"/>
  <span class="next_button"><a href="#" data-role="none" id="nxt_btn2"></a></span>
</span>

Button Bind Code

$('#nxt_btn2').bind('click', function () {
  var reqURL = '/j_security_check';
  var options = {};
  options.parameters = {
    j_username : $('#mobnum').val(),
    j_password : $('#email').val()
  };

  options.headers = {};

  pushAppRealmChallengeHandler.submitLoginForm(reqURL, options, pushAppRealmChallengeHandler.submitLoginFormCallback);

});

Solution

  • The Google Cloud Messaging for Android was not enabled. So I was getting subscribed and messages were being sent form MobileFirst server to GCM but since the API was not enabled in GCM I was not getting the notfications on my device.

    Steps Taken

    1. Enabled Cloud Messaging for Android API in GCM
    2. Regenerated the API Key.

    Special thanks to @kawineshSK and IdanAdar