Uploaded image for project: 'Appcelerator Modules'
  1. Appcelerator Modules
  2. MOD-2276

Android CloudPush: Callback event did not fire if close app and remove from recent

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: CloudPush
    • Labels:
      None
    • Environment:

      TISDK 5.3.1 and 5.2.2
      CloudPush Module 3.4.1

    • Story Points:
      5
    • Sprint:
      2018 Sprint 05 SDK, 2018 Sprint 10 SDK, 2018 Sprint 11 SDK, 2018 Sprint 12 SDK, 2018 Sprint 13 SDK, 2018 Sprint 14 SDK, 2018 Sprint 15 SDK, 2018 Sprint 16 SDK, 2016 Sprint 17 SDK, 2018 Sprint 18 SDK, 2018 Sprint 19 SDK, 2018 Sprint 20 SDK, 2018 Sprint 21, 2018 Sprint 22

      Description

      Reproduce Step

      1. Run the following code in app.js

      var win = Ti.UI.createWindow({});
       
      var CloudPush = require('ti.cloudpush'); 
      var Cloud = require('ti.cloud');
       
      var deviceToken = null;
       
      CloudPush.singleCallback = true;
       
      CloudPush.retrieveDeviceToken({	
      	success: function deviceTokenSuccess(e) {
      		deviceToken = e.deviceToken;
      		Ti.API.info('Device Token: ' + e.deviceToken);
             		
             	loginUser();
          },
          error: function deviceTokenError(e) {
              alert('Failed to register for push! ' + e.error);
          }
      });
       
      CloudPush.addEventListener('callback', function (evt) {
          alert(evt.payload);
          Ti.API.info("CallBack fired: \n" + evt.payload);
      });
      CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
      	alert('Tray Click Launched App (app was not running)');
          Ti.API.info('Tray Click Launched App (app was not running)');
      });
      CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
      	alert('Tray Click Focused App (app was already running)');
          Ti.API.info('Tray Click Focused App (app was already running)');
      });
       
      function loginUser(){
          Cloud.Users.login({
              login: 'sliang@appcelerator.com',
              password: '1234'
          }, function (e) {
              if (e.success) {
                  Ti.API.info('Login successful');
                  subscribeToChannel();
              } else {
                  alert('Error:\n' +
                      ((e.error && e.message) || JSON.stringify(e)));
              }
          });
      }
       
      function subscribeToChannel(){
          Cloud.PushNotifications.subscribe({
              channel: 'alert',
              device_token: deviceToken,
              type: Ti.Platform.name == 'android' ? 'android' : 'ios'
          }, function (e) {
              if (e.success) {
                  Ti.API.info('Subscribed');
              } else {
                  alert('Error:\n' +
                      ((e.error && e.message) || JSON.stringify(e)));
              }
          });
      }
       
      win.open();
      

      2. Send push notification from dashboard, make sure the push working well.
      3. Close the app and remove it from recent.
      4. Send push notification again.
      5. Click the tray notification to open the app.

      Expect Result

      callback and trayClickLaunchedApp event should be triggered both.

      Actual Result

      only trayClickLaunchedApp event triggered, callback event did not get called.

      Note

      If you only put the app in background, then it works well as expected.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                sliang Shuo Liang
              • Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Git Source Code