Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25022

Android : CloudPush Callback didnt fire after open a new window in Alloy

    Details

    • Type: Bug
    • Status: Reopened
    • Resolution: Unresolved
    • Affects Version/s: Release 6.0.3
    • Fix Version/s: None
    • Component/s: None
    • Environment:

      Description

      The CloudPush Callback is not working after the app open a new window.

      Ti.Cloud Modules Version : 3.2.11
      Ti.Cloudpush Modules Version: 4.0.3
      Ti.SDK Version : 6.0.3 GA

      The CloudPush Callback only fired when i first launched the app and didn't open a new window whenever a new notifications come in.

      That means it will not fire anymore if i open a second window and a new notification come in.
      But, the callback will show the previous notification which didn't show in the second window after i kill the app and relaunch it.

      Besides that, the CloudPush trayClickLaunchedApp and trayClickFocusedApp EventListener not working also.

      There are some Warning showed in the console when i stayed in second window and receive a new notification come in as the screenshort attached.

      Sample code of my project:

      -----------------------------------------------------------------------------------------------------------------------------
      alloy.js

      var CloudPush = require('ti.cloudpush');
      CloudPush.debug = true;
      CloudPush.enabled = true;
      CloudPush.showTrayNotificationsWhenFocused = true;
      CloudPush.showTrayNotification = true;
      CloudPush.focusAppOnPush = false;
      var deviceToken = null;
      var Cloud = require('ti.cloud');
      Cloud.debug = true;

      CloudPush.retrieveDeviceToken(

      { success: deviceTokenSuccess, error: deviceTokenError }

      );

      function deviceTokenSuccess(e)

      { deviceToken = e.deviceToken; loginDefault(); }

      function deviceTokenError(e)

      { console.log('Failed to register for push notifications! ' + e.error); alert('Failed to register for push notifications! ' + e.error); }

      function loginDefault(e) {
      Cloud.Users.login(

      { login: 'test@gmail.com', password: 'TESTabc123' }

      , function (e) {
      if (e.success)

      { defaultSubscribe(); // alert("Successfully Loged In"); }

      else

      { // alert('Error login-----: ' + ((e.error && e.message) || JSON.stringify(e))); }

      });
      }

      function defaultSubscribe() {
      Cloud.PushNotifications.subscribe(

      { channel: 'test1', device_token: deviceToken, type: 'android' }

      , function (e) {
      if (e.success)

      { alert('Device Subscribed!'); }

      else

      { alert('Error defaultSubscribe : ' + ((e.error && e.message) || JSON.stringify(e))); }

      });
      }

      CloudPush.addEventListener('callback', function (evt)

      { alert("Notification received: " + evt.payload); }

      );

      CloudPush.addEventListener('trayClickLaunchedApp', function (evt)

      { Ti.API.info('Tray Click Launched App (app was not running)'); }

      );

      CloudPush.addEventListener('trayClickFocusedApp', function (evt)

      { Ti.API.info('Tray Click Focused App (app was already running)'); }

      );

      -----------------------------------------------------------------------------------------------------------------------------

      index.js

      $.index.open();

      function NEWWIN(e)

      { Alloy.createController("Newwin").getView().open(); $.index.close(); }

      -----------------------------------------------------------------------------------------------------------------------------
      index.xml

      <Alloy>
      <Window class="container">

      <Button id="btnSend" title="NEW WINDOWS" onClick="NEWWIN"></Button>
      </Window>
      </Alloy>

      -----------------------------------------------------------------------------------------------------------------------------
      Newwin.js

      var args = $.args;

      function BACKUPINDEX(e)

      { Alloy.createController("index").getView().open(); $.container.close(); }

      -----------------------------------------------------------------------------------------------------------------------------

      Newwin.xml

      <Alloy>
      <Window class="container" id="container">

      <Label id="pushRegistration">New window</Label>

      <Button id="btnSend" title="BACK INDEX" onClick="BACKUPINDEX"></Button>
      </Window>
      </Alloy>

      -----------------------------------------------------------------------------------------------------------------------------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Yellowcube Yellowcube
              • Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-10931
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code