Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6134] Notification Bug on SDK 8.0.0

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionHold
Resolution Date2019-02-20T17:05:50.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid
ReporterAndreas Pingas
AssigneeShak Hossain
Created2019-02-09T09:24:13.000+0000
Updated2019-02-20T17:05:51.000+0000

Description

When the app is not running and the user receives a notification, the Listener trayClickLaunchedApp is not fired.
WARN] :   W/System.err: java.io.FileNotFoundException: Resources/sound/default
[WARN] :   W/System.err: 	at android.content.res.AssetManager.openAssetFd(Native Method)
[WARN] :   W/System.err: 	at android.content.res.AssetManager.openFd(AssetManager.java:394)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.getAndTransferFile(APSCloudPush.java:617)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:489)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:306)
[WARN] :   W/System.err: 	at com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)
[WARN] :   W/System.err: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:3291)
[WARN] :   W/System.err: 	at android.app.ActivityThread.-wrap17(Unknown Source:0)
[WARN] :   W/System.err: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1706)
[WARN] :   W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:105)
[WARN] :   W/System.err: 	at android.os.Looper.loop(Looper.java:173)
[WARN] :   W/System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6698)
[WARN] :   W/System.err: 	at java.lang.reflect.Method.invoke(Native Method)
[WARN] :   W/System.err: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
[WARN] :   W/System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
[ERROR] :  EnhancedIntentService: binding to the service failed

Comments

  1. Sharif AbuDarda 2019-02-12

    Hello, Can you please share the code that you are using for the push receive? Thanks.
  2. Andreas Pingas 2019-02-13

       Ti.Android.NotificationManager.createNotificationChannel({
           id:'default',
           name:'Miscellaneous',
           importance:Ti.Android.IMPORTANCE_DEFAULT,
           showBadge:true,
           enableVibration:true,
           enableLights:true
       });
       		
       var CloudPush = require('ti.cloudpush');
       
       var deviceToken = null;
       
       CloudPush.retrieveDeviceToken({
           success:function(e) {
       	    deviceToken = e.deviceToken;
       	},
           error:function(e) {
       		
       	}
       });
       
       CloudPush.showTrayNotificationsWhenFocused = true;
       CloudPush.showTrayNotification = true;
       CloudPush.focusAppOnPush = false;
       CloudPush.singleCallback = false;
       
       CloudPush.addEventListener('trayClickFocusedApp', function(e) {	
       	var data = JSON.parse(e.payload).android;
       	Ti.API.info(data);
       });
       
       CloudPush.addEventListener('trayClickLaunchedApp', function(e) {
       	var data = JSON.parse(e.payload).android;
       	Ti.API.info(data);
       });
       
  3. Sharif AbuDarda 2019-02-13

    Hello [~andreas.pingas], Are you sending a sound with your push notification, did you app have the sound resource inside? what is your cloudpush version? Can you try with the below code, put your credentials in the login. Thanks.
       var win = Ti.UI.createWindow({
           backgroundColor : '#ccc',
           title : 'Android Cloud Push Notification'
       });
         
       var CloudPush = require('ti.cloudpush');
       CloudPush.debug = true;
       CloudPush.enabled = true;
       CloudPush.singleCallback = true;
         
       var deviceToken=null;
       var Cloud = require('ti.cloud');
       Cloud.debug = true;
         
       var submit = Ti.UI.createButton({
           title : 'Register For Push Notification',
           color : '#000',
           height : 60,
           width : 200,
           top : 100,
       });
         
       win.add(submit);
         
       submit.addEventListener('click', function(e) {
           loginDefault();
       });
         
       CloudPush.retrieveDeviceToken({
           success : deviceTokenSuccess,
           error : deviceTokenError
       });
         
       // Save the device token for subsequent API calls
       function deviceTokenSuccess(e) {
           deviceToken = e.deviceToken;
       }
         
       function deviceTokenError(e) {
           alert('Failed to register for push notifications! ' + e.error);
       }
         
       // Process incoming push notifications
       var listenersAdded = false;
       win.addEventListener('open', function() {
           if (listenersAdded) {
               return;
           }
        
           // Process incoming push notifications
           CloudPush.addEventListener('callback', function(evt) {
               alert("Notification received: " + evt.payload);
               Ti.API.info("-------> Notification received: " + 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)');
           });
        
           listenersAdded = true;
       });
         
       function loginDefault(e) {
           // At first you need to create an user from the application dashboard
           // Then login that email and password
           Cloud.Users.login({
               login : 'sliang@appcelerator.com',
               password : '1234'
           }, function(e) {
               if (e.success) {
                   alert("login success");
                   defaultSubscribe();
               } else {
                   alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));
               }
           });
       }
         
       function defaultSubscribe() {
           Cloud.PushNotifications.subscribe({
               channel : 'Android Test',
               device_token : deviceToken,
               type : 'gcm'
           }, function(e) {
               if (e.success) {
                   alert('Subscribed for Push Notification!');
               } else {
                   alert('Error:' + ((e.error && e.message) || JSON.stringify(e)));
               }
           });
       }
       win.open();
       
  4. Andreas Pingas 2019-02-14

    I use the Android sdk build-tools 28.0.3, to ti.cloudpush 5.2.0, android SDK 28, sound is set to default. The example you have send seems that its always working. My example, on the other hand is not working properly. The CloudPush.retrieveDeviceToken is fired and then i can send one notification only. When the notification reaches the device then the following issue arises and then the device stops receiving notifications. The CloudPush.retrieveDeviceToken process has to take place again in order to start receiving. [ERROR] : EnhancedIntentService: binding to the service failed I will check if any of the following makes an issue and i will let you know. firebase.core firebase.analytics ti.playservices ti.admob
  5. Andreas Pingas 2019-02-14

    The bug starts with the var CloudPush = require('ti.cloudpush'); It does not mean that the GooglePlayServices are loading. They might load a few seconds later. If the commands load οne after another all the commands the most probable is that this would not work. :) A temporary solution i have found is the following and always works:
       var PlayServices = require('ti.playservices');	
       var CloudPush = require('ti.cloudpush');
       
       var deviceToken = null;
       
       CloudPush.retrieveDeviceToken({
           success:function(e) {
       	    deviceToken = e.deviceToken;
       	},
           error:function(e) {
       		
       	}
       });
       
       CloudPush.showTrayNotificationsWhenFocused = true;
       CloudPush.showTrayNotification = true;
       CloudPush.focusAppOnPush = false;
       CloudPush.singleCallback = false;
       
       var isGooglePlayServicesAvailableInterval = setInterval(function() {
       	
       	if (PlayServices.isGooglePlayServicesAvailable() == PlayServices.RESULT_SUCCESS) {
       		clearInterval(isGooglePlayServicesAvailableInterval);
       
       	    CloudPush.addEventListener('callback', function(evt) {
       	        alert("Notification received: " + evt.payload);
       	        Ti.API.info("-------> Notification received: " + 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)');
       	    });
       	}    
       							    
       }, 500);
       
  6. Sharif AbuDarda 2019-02-20

    Hello [~andreas.pingas], You can look into another report of I believe the similar issue TIMOB-18125.

JSON Source