0

I develop a new Android application using appcelerator. I use ti.cloudpush to use push notifications from firebase like this example; the notification is sent successfully and shown in the notification bar of the device if the application is in background, but not received when the application is in foreground or closed although the result of sending process is "successful".

I need to make it like facebook messenger, shown in the device screen if the application is closed. I tried several other modules like "ti.goosh" and "nl.vanvianen.android.gcm", I found out that in the Android world I should write "START_STICKY" somewhere in the application to enforce the service to keep processing even if the application been closed.

I tried to develop separate service and call it in the tiapp.xml, but the service also been killed if the application is closed.

Edit is there any sdk tools must be installed which appcelerator need to use in the build process

Community
  • 1
  • 1
  • Are you sure you are not receiving PN in app's closed state? Because if you are receiving them in background mode, then you must be receiving them in kill state as well. There's no need to write any additional service codes if you are using ti.cloudpush. For more info, can you share your project environment details & some code snippet of how you have written code for PN? – Prashant Saini Oct 20 '17 at 02:48
  • There's nothing advance to do to receive push in kill-state. I have been using ti.cloudpush in many apps without any hiccups ever. Can you also share what exactly are you using like GCM or FCM? – Prashant Saini Oct 20 '17 at 02:52
  • i use FCM ,i make a file called notification.js and save it in app/lib , i require this file in the index.js and initialize it , the token saved with the channel called android. – MG Developer Oct 21 '17 at 08:57

2 Answers2

0

If android device has Google Play Services installed, you don't need any actions to make push notificatons work in background or foreground. I am using ti.goosh module and it's working perfect. I think you are sending wrong data to device to show notification properly, i'm sending this data:

data: {
    "data":
        {
            'title': 'Notification title',
            'alert': 'Short user notification text, when it is shown as pop up after receiving notification',
            'big_text': 'Long notification text, when user expanding it',
            'sound': 'default', //notification sound (here is default to user android settings)
            'force_show_in_foreground': true, //is notification must be shown when application in foreground
            'color': '#0dd149' //background color of notification icon
        }
}
Ked
  • 134
  • 8
0

I solved it as follow.

the file /app/platform/android/res/values/strings.xml
is necessary

and has the google_app_id of the firebase project

<?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <string name="google_app_id">1:11111111111:android:aaaaaaaaa</string>
</resources>

This file communicates with firebase module.

user1948083
  • 151
  • 1
  • 3