[AC-4744] cloudpush not calling callback when application is running - forground
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-02-01T20:32:12.000+0000 |
Affected Version/s | Appcelerator Studio 4.5.0 |
Fix Version/s | n/a |
Components | Appcelerator Modules, Arrow Push, Titanium SDK & CLI |
Labels | n/a |
Reporter | Anis Vora |
Assignee | Shak Hossain |
Created | 2017-01-19T11:21:25.000+0000 |
Updated | 2017-02-01T20:32:13.000+0000 |
Description
We implemented Android push in application but having one small issue.
When application is running/foreground/active it is not calling callback function.
In debug window we can see this when new message came.
[INFO] : APSCloudPush: receivePayload: {"android":{"badge":"0","alert":"New message(s) received","sound":"default","icon":"icon","vibrate":true,"title":"CareChatZ"}}
[INFO] : APSCloudPush: background: true
[INFO] : APSCloudPush: processCallbackIfInstantiated payload: {"android":{"badge":"0","alert":"New message(s)
received","sound":"default","icon":"icon","vibrate":true,"title":"CareChatZ"}}
Please help
Hello, Send the sample code that regenerates the issue. Also, Use the latest SDK 6.0.1.GA for your build.
Hello, Thanks for prompt reply , can't switch to 6.0.1 GA as we are using titutorial.audiorecorder module and it is not compatible with that. Now about code , it is all same as http://docs.appcelerator.com/platform/latest/#!/api/Modules.CloudPush {noformat} if(isAndroid) { CloudPush = require('ti.cloudpush'); CloudPush.showTrayNotificationsWhenFocused = false; CloudPush.showAppOnTrayClick = true; CloudPush.showTrayNotification = true; CloudPush.debug = true; } CloudPush.addEventListener('callback', function (evt) { alert(evt.payload); }); {noformat} I also checked Androidmanifest.xml file from build directory and all seems to be good. Thanks in advance. Regards, Anis
Hello, I just checked. callback is called successfully as alert, when App is running in foreground.I am running in Android 6.0.1. with SDK 6.0.1.GA. Use the below code.
Thanks.
Hello, Thanks for your reply. Today we found interesting thing , that CloudPush variable was part of config.js which have all common functions and variables and that is getting included in all page off application. Now today we move that CloudPush variable and event listener to app.js and .... bingo .. it start working , but with small problem it works only in first screen of application which is getting called from app.js .. so if we move to other screen in app it is not calling that callback event. Do you have any idea on that ? Regard, Anis
Hello, Can you share a sample project that we can use to reproduce the issue? We will investigate it.
Hello, Thanks you very much for all your continues support. I sent you sample code and all required details , please let me know if anything more is require. Regards, Anis
Hello, Your sample app has lots of issue like ti.include, which is deprecated. I made a sample app myself which is working as expected. See my sample app. app.js
NewWindow.js
First use the above code in a new project. Create a new user in the arrowDB console in platform and provide the email and pass in the above code. As
Configure firebase push notification for the app in the console. Click register for push notification for login(see the success alert) Click subscribe device for device subscription(see the success alert) Click New window to open another window. Send push notification from the console. See the alert open as the push received and whole lot. Thanks.
Hello Sharif, Really thanks for all your help and time you spent to help us. Finally we found the problem , it was because of win.close .. like as part of good practice we are closing previous win once new window get loaded. So, it works fine in first screen which is loaded from app , and if we move to other screen then that win is getting closed and callback stops working. Now , one small problem .. that push notification icon in notification tray is plain white square instead of actual logo/icon. Can you help with that ? or do we need to write in other post ? Regards, Anis
Hello, You need to put a custom icon in project "platform/android/res/drawable" directory. This icon will be used to show notification bar and be used as icon of notification item in the notification center. provide the name of the file without the extinction in icon field when you send the push notification from platform. If the field is empty default icon will be used. See guide: http://docs.appcelerator.com/platform/latest/#!/guide/Sending_and_Scheduling_Push_Notifications Android-specific payload fields/icon.