morinel / gcmpush Goto Github PK
View Code? Open in Web Editor NEWTitanium Module for Android Push
License: Apache License 2.0
Titanium Module for Android Push
License: Apache License 2.0
This module works on Ti 4.1.0.GA
?
Is there any way to add listener when user click on notifications on android ?
User with Android 4.1.2 is getting a crash with the above error message. As shown in Appcelerator (crittercism) crash logs:
0 java.lang.NoSuchMethodError: android.app.PendingIntent.getCreatorPackage
1 at nl.vanvianen.android.gcm.GCMIntentService.onMessage(GCMIntentService.java:453)
2 at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
3 at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
4 at android.os.Handler.dispatchMessage(Handler.java:99)
5 at android.os.Looper.loop(Looper.java:137)
6 at android.os.HandlerThread.run(HandlerThread.java:60)
I've scanned the code and don't see this method being directly called, nor is getTargetPackage() which is the orig name for this function. But, maybe it's something coming from a dependency.
Hi again, if app is foreground, notification callback event fires but notification isn't lost from notification bar.
Hello,
I am using titanium SDK 6.1.3, while integrating module version 1.6, getting following error:
[ERROR] : Failed to package application:
[ERROR] :
[ERROR] : /Users/Moiz/Documents/Titanium_Studio_Workspace/WeightApp/build/android/res/drawable/background.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
[ERROR] : /Users/Moiz/Documents/Titanium_Studio_Workspace/WeightApp/build/android/res/drawable-xxhdpi/icon_back_ipad_b3d9167881.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
[ERROR] : /Users/Moiz/Documents/Titanium_Studio_Workspace/WeightApp/build/android/res/drawable-xxhdpi/slider_icon_user_default_3e565acb38.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
[ERROR] : /Users/Moiz/Documents/Titanium_Studio_Workspace/WeightApp/build/android/res/drawable-xxhdpi/textfeild_sen_an_email_2x_67da7dca9b.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
[ERROR] : /Users/Moiz/Documents/Titanium_Studio_Workspace/WeightApp/build/android/AndroidManifest.xml:33: Tag attribute name has invalid character '$'.
[ERROR] : /Users/Moiz/Documents/Titanium_Studio_Workspace/WeightApp/build/android/AndroidManifest.xml:47: Tag attribute name has invalid character '$'.
Can you help me resolving this issue.
Hi!
I need launch a specific function when the app has received a push notification. When app is opened or in background mode I can show an alert with the push notification text, but if app is closed I can not show the alert.
Is there a way to achieve this?
Regards!
Hi,
This is be related to the issue App open from PushNotification click without payload where @cjadhav and @DFoxinator ask about getting the payload on clicking on notification.
To differentiate bringing the app to the foreground via a notification tap from just bringing the app to the foreground normally, I have tried the following:
launcherIntent.putExtra("PUSH_LAUNCH", true);`
win.activity.addEventListener("newIntent", function(e) {
console.log('NEW INTENT ' + JSON.stringify(e.intent) + ' WITH EXTRA: ' + e.intent.getBooleanExtra('PUSH_LAUNCH', false));
});
and
Ti.Android.currentActivity.addEventListener('newintent', function(e) {
console.log('NEW INTENT ' + JSON.stringify(e.intent) + ' WITH EXTRA: ' + e.intent.getBooleanExtra('PUSH_LAUNCH', false));
});
@FokkeZB opened a JIRA ticket :Android newintent event not fired so that could be reason I do not get it.
Do you know another way to do it?
Hello,
I have an issue where users can't open the app when a push receive. Once user clicks on the notification, app opens an stays in the splash screen..sometimes it's black.
Thanks!
Will this library be rebuilt for Titanium sdk 6.0.0 support?
I am trying to use this module.
but when I run my app am getting below error.
is this module support for latest Titanium SDK Versions?
In feature are you providing support when new titanium SDK released?
[ERROR] : art: dlopen("/data/app/com.test-1/lib/arm/libnl.vanvianen.android.gcm.so", RTLD_LAZY) failed: dlopen failed: library "libstlport_shared.so" not found
[ERROR] : TiApplication: (main) [60,1770] Sending event: exception on thread: main msg:java.lang.UnsatisfiedLinkError: dlopen failed: library "libstlport_shared.so" not found; Titanium 6.3.0,2017/10/31 18:13,undefined
[ERROR] : TiApplication: java.lang.UnsatisfiedLinkError: dlopen failed: library "libstlport_shared.so" not found
[ERROR] : TiApplication: at java.lang.Runtime.loadLibrary(Runtime.java:371)
[ERROR] : TiApplication: at java.lang.System.loadLibrary(System.java:988)
[ERROR] : TiApplication: at org.appcelerator.kroll.runtime.v8.V8Runtime.loadExternalModules(V8Runtime.java:151)
[ERROR] : TiApplication: at org.appcelerator.kroll.runtime.v8.V8Runtime.initRuntime(V8Runtime.java:118)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollRuntime.doInit(KrollRuntime.java:205)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:114)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollRuntime.init(KrollRuntime.java:136)
[ERROR] : TiApplication: at com.test.TestApplication.onCreate(TestApplication.java:46)
[ERROR] : TiApplication: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1035)
[ERROR] : TiApplication: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4638)
[ERROR] : TiApplication: at android.app.ActivityThread.access$1500(ActivityThread.java:155)
[ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:135)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5343)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:372)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
My environments:
Operating System = Mac OS X 10.11.3
Node.js Version = 4.6.0
npm Version = 2.15.9
Titanium CLI Version = 5.0.14
Titanium SDK Version = 6.3.0.GA
Is it possible to use big view notifications on Android so that the message body isn't truncated?
When I include the module in my project I am getting the following error, can you let me know how I should go about resolving this?
[ERROR] : Failed to run dexer:
[ERROR] :
[ERROR] : UNEXPECTED TOP-LEVEL EXCEPTION:
[ERROR] : java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GoogleCloudMessaging$1;
[ERROR] : at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
[ERROR] : at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
[ERROR] : at com.android.dx.command.dexer.Main.processClass(Main.java:685)
[ERROR] : at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
[ERROR] : at com.android.dx.command.dexer.Main.access$600(Main.java:78)
[ERROR] : at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[ERROR] : at com.android.dx.command.dexer.Main.processOne(Main.java:596)
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
[ERROR] : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
[ERROR] : at com.android.dx.command.dexer.Main.run(Main.java:230)
[ERROR] : at com.android.dx.command.dexer.Main.main(Main.java:199)
[ERROR] : at com.android.dx.command.Main.main(Main.java:103)
[ERROR] : 1 error; aborting
TRACE | titanium exited with exit code 1
ERROR | Error: ti run exited with error code 1
at ChildProcess.<anonymous> (/Users/matthewlanham/.appcelerator/install/5.0.4/package/node_modules/appc-cli-titanium/plugins/run.js:92:66)
at ChildProcess.emit (events.js:98:17)
at Process.ChildProcess._handle.onexit (child_process.js:809:12)
TRACE | Sending exit signal to titanium process: 67493
Should I be calling gcm.registerPush() every time the app opens? Seems strange to do that, but it also seems to be the only way to attach the callback. Am I missing something?
I have 12 of these crash reports in release:
java.lang.NullPointerException: Attempt to invoke virtual method 'void nl.vanvianen.android.gcm.GCMModule.sendSuccess(java.lang.String)' on a null object reference
at nl.vanvianen.android.gcm.GCMIntentService.onRegistered(GCMIntentService.java:58)
at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:295)
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:197)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:61)
Would it be easy to add compatibility to the new FCM which Google is pushing now?
https://developers.google.com/cloud-messaging/android/android-migrate-fcm
WARNING
Users that have the APK with version code 215 may need to accept the android.permission.USE_CREDENTIALS permission, which may result in them not upgrading to this version of the app.
Permission is not needed anymore and produces an error when uploading an app to the store now
Setup and start register:
var push = require("/push").create({
senderID: 'SENDER_ID'
});
push.registerPush({
success: onRegisterPush,
error: onRegisterError,
callback: onPushCallback
});
function onRegisterPush(e) {
if (OS_ANDROID) {
console.log("SUCCESS PUSH " + JSON.stringify(e));
api.register({
pushid: e.registrationId
}, function(video) {
// do stuff with the video
});
push.subscribe({
topic: "global",
success: onSubSuccess
});
}
Log:
[INFO] REGISTER PUSH SENDER_ID
[DEBUG] GCMModule: (KrollRuntimeThread) [2,250] registerPush called
[DEBUG] GCMRegistrar: Resetting backoff for com.name.app
[TRACE] GCMRegistrar: Registering app com.name.app of senders SENDER_ID
[TRACE] GCMRegistrar: Creating pending intent to get package name
[DEBUG] GCMModule: (KrollRuntimeThread) [8,258] get registrationId property
[INFO] SUCCESS PUSH {"registrationId":"PUSH_ID"}
[DEBUG] GCMModule: (main) [32,290] onPause com.name.app.appActivity@207cb33e (true)
[INFO] ::RESTE:: CALL_SERVER
[INFO] SUBSCRIBE PUSH SENDER_ID
[DEBUG] GCMModule: (main) [591,881] onStop com.name.app.appActivity@207cb33e (true)
[TRACE] GCMBroadcastReceiver: onReceive: com.google.android.c2dm.intent.REGISTRATION
[TRACE] GCMBroadcastReceiver: GCM IntentService class: nl.vanvianen.android.gcm.GCMIntentService
[TRACE] GCMBaseIntentService: Intent service name: GCMIntentService--2
[DEBUG] GCMBaseIntentService: handleRegistration: registrationId = PUSH_ID, error = null, unregistered = null
[DEBUG] GCMRegistrar: Resetting backoff for com.name.app
[TRACE] GCMRegistrar: Saving regId on app version 1
[DEBUG] GCMIntentService: (IntentService[GCMIntentService--2]) [745,1626] Registered: PUSH_ID
[INFO] SUCCESS PUSH {"registrationId":"PUSH_ID"}
[INFO] ::RESTE:: CALL_SERVER
[INFO] SUBSCRIBE PUSH SENDER_ID
::RESTE:: CALL_SERVER is called twice because the success event is called twice. Is that normal?
The Push.sender_id is the same so its just an identical server call
I created an issue ticket yesterday. I made what you said but issue is continue. I think may be it is a bug. I remove group line from my settings but only one notification (which is last) showing in android notification area still. I am seeing one more received notifications on console and logcat logs. Do you have any suggestion?
Thank you in advance.
Hi guy.
Thanks for this module, it is really great. I noticed that, when you send more than one notification, only the last is shown on the device (the old is replaced). This seems to be happening because you hardcoded this:
((NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE)).notify(1, notification);`
And I see later that @kerbooo made a pull request but it is waiting for approval.
I leave this message here for future references (the kerbooo "issue" is not well "titled" for searching
Hey,
Thanks for creating this awesome module. It is much appreciated.
My notifs are working fine when my app is in the background. When I close the app and try to receive a notification, on the device I get "Unfortunately, myapp has stopped."
In adb logcat, I see the following error:
E/AndroidRuntime(10364): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean nl.vanvianen.android.gcm.GCMModule.isInForeground()' on a null object reference
E/AndroidRuntime(10364): at nl.vanvianen.android.gcm.GCMIntentService.onMessage(GCMIntentService.java:340)
E/AndroidRuntime(10364): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
E/AndroidRuntime(10364): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E/AndroidRuntime(10364): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(10364): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(10364): at android.os.HandlerThread.run(HandlerThread.java:61)
Am I doing something incorrectly?
Any help is appreciated.
Is it possible to get more than one previous alert with getLastData()? If there has been more than one alert by the time the user checks the alert, only the most recent one can be retrieved.
Hey man thank u for this module but i have a problem when i put it in tiapp it give me this module doesn't supported for this sdk 5.0.2.GA
this error please
[ERROR] : Failed to run dexer:
[ERROR] :
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmListenerService;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmListenerService$1;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmListenerService$2;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmNetworkManager;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmPubSub;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmReceiver;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmTaskService;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GcmTaskService$zza;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GoogleCloudMessaging;
[ERROR] :
[ERROR] : UNEXPECTED TOP-LEVEL EXCEPTION:
[ERROR] : java.lang.RuntimeException: Translation has been interrupted
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:615)
[ERROR] : at com.android.dx.command.dexer.Main.runMultiDex(Main.java:368)
[ERROR] : at com.android.dx.command.dexer.Main.runDx(Main.java:289)
[ERROR] : at com.android.dx.command.dexer.Main.main(Main.java:247)
[ERROR] : at com.android.dx.command.Main.main(Main.java:94)
[ERROR] : Caused by: java.lang.InterruptedException: Too many errors
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:607)
[ERROR] : ... 4 more
Hi, I've installed into my project the 1.4 release and AppC Studio doesn't detect it.
With 1.3 works 100%
Thx.
Hi, is it possible send push notification with dinamically server-side smallIcon and largeIcon?
hello,
im using SDK 5.4.0 GA and 1.7 version of the module
this is my code
var gcm = require("nl.vanvianen.android.gcm");
/* If the app is started or resumed act on pending data saved when the notification was received */
var lastData = gcm.getLastData();
if (lastData) {
Ti.API.info("Last notification received " + JSON.stringify(lastData));
gcm.clearLastData();
}
gcm.registerPush({
senderId : 'XXXXXXXX',
notificationSettings : {
sound : '', /* Place sound file in platform/android/res/raw/mysound.mp3 */
smallIcon : 'appicon.png', /* Place icon in platform/android/res/drawable/notification_icon.png */
largeIcon : 'appicon.png', /* Same */
vibrate : true, /* Whether the phone should vibrate */
insistent : true, /* Whether the notification should be insistent */
group : 'MyNotificationGroup', /* Name of group to group similar notifications together */
localOnly : false, /* Whether this notification should be bridged to other devices */
priority : +2, /* Notification priority, from -2 to +2 */
bigText : true,
/* You can also set a static value for title, message, or ticker. If you set a value here, the key will be ignored. */
// title: '',
// message: '',
// ticker: ''
/* Add LED flashing */
ledOn : 200,
ledOff : 300
},
success : function(event) {
Ti.API.info("Push registration success: " + JSON.stringify(event));
synchronize(event);
},
error : function(event) {
Ti.API.error("Push registration error: " + JSON.stringify(event));
alert("Fail to register for remote push notification");
},
callback : function(event) {
Ti.API.info("Push callback = " + JSON.stringify(event));
// Called when a notification is received and the app is in the foreground
//TODO print message notification
var dialog = Ti.UI.createAlertDialog({
title : 'Push received',
message : JSON.stringify(event.data),
buttonNames : ['View', 'Cancel'],
cancel : 1
});
dialog.addEventListener("click", function(event) {
dialog.hide();
if (event.index == 0) {
//Do stuff to view the notification
}
});
dialog.show();
}
});
and i got a success registration and just after an error message
[INFO] : Push registration success: {"registrationId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX8ny0B0KQa9UrCn8s","success":true}
and just after
[ERROR] : GCMIntentService: (IntentService[GCMIntentService--2]) [197,4105] Error: INVALID_SENDER
[ERROR] : GCMModule: (IntentService[GCMIntentService--2]) [1,4106] INVALID_SENDER
something missing? im sure that im calling this library one time !
Hello,
Previously we was using a different module for push notification and there was a issue in that. It was returning multiple registration id for the same devices. In this case one user was getting multiple push notification for the same message. I read from the link given below that we should use Canonical ID to fix this problem. Could you please help on this.
Stackoverflow
I'm trying to implement gcmpush module but I'm not receiving any
messages. I guess because I've did something wrong in the setup. Perhaps someone
could help.
I've inserted the module and used the example code with my project id. Inside
the app I receive:
"Push registration success: {"registrationId":"APA91bH...."}"
Then I want to use https://github.com/edgarmiro/GCM-PHP-Server-Push-Message to
send a push and add the server api key to the broadcast example (feedback:
"message_id..."). But I don't receive anything on the device.
Anything I could check to see where the error is?
Hi, we are receiving these errors in Google Play, all happened on Android 6.0.
Could you look into it? We use the release 1.7 of the module.
java.lang.NullPointerException: Attempt to invoke virtual method 'void nl.vanvianen.android.gcm.GCMModule.sendSuccess(java.lang.String)' on a null object reference
at nl.vanvianen.android.gcm.GCMIntentService.onRegistered(GCMIntentService.java:61)
at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:295)
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:197)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.os.HandlerThread.run(HandlerThread.java:61)
The sound of the notification aren't playing.
_pushOptions = {
senderId: 'xxxxxxxx' // It's the same as your project id
, notificationSettings: {
vibrate: true // Whether the phone should vibrate
, insistent: false // Whether the notification should be insistent
, group: 'News' // Name of group to group similar notifications together
, localOnly: false // Whether this notification should be bridged to other devices
, priority: 2 // Notification priority, from -2 to 2
}
};
If I don't specify an sound, it won't play any ?
There's a default sound that I can use ? Thanks
<module platform="android" version="1.4">nl.vanvianen.android.gcm</module>
Hi Yes I know last 3 issue tickets are mine. I need to know this is a bug or my wrong setting error? Please answer me because I have no time for publishing my app :(
My sample logcat report as below. One more notification received from my remote server to android phone, every notification data appear on logcat like below.
But when I would like to show my notifications using grouping or separately, group setting doesn't work. Every notification is lost when new one came.
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [527,568086] Push notification received
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568086] Message key: "from" value: "xxxxxxx"
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568086] Message key: "view" value: "viewMain"
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [1,568087] Message key: "sound" value: "my.mp3"
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568087] Message key: "title" value: "Sample title 1"
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568087] Message key: "message" value: "Sample message 1"
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568087] Message key: "collapse_key" value: "do_not_collapse"
E/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [81,568168] Invalid setting ledOn, should be Integer
E/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568168] Invalid setting ledOff, should be Integer
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [2,568170] Title: Sample message 1
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568170] Message: Sample message 1
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568170] Ticker: null
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568170] Creating notification...
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [8,568178] Group: News
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568178] LocalOnly: false
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568178] Priority: 2
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568178] bigText: true
D/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [2,568180] Sound specified in notification
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568180] Sound buzzer.mp3
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568180] Vibrate: true
I/GCMIntentService(28427): (IntentService[GCMIntentService--2]) [0,568180] Insistent: false
D/TiAPI (28427): [TiPush] onReceive Push callback = {"inBackground":true,"data":{"sound":"my.mp3","title":"Sample title 1","message":"Sample title 1 ","from":"xxxxxxxxx","collapse_key":"do_not_collapse","view":"viewMain"}}
I
My Appceleretor settings as below
notificationSettings : {
sound : 'bounce.mp3', //> Place sound file in platform/android/res/raw/mysound.mp3
smallIcon : 'notification.png', //> Place icon in platform/android/res/drawable/notification_icon.png
largeIcon : 'appicon.png', //> Same
vibrate : true, //> Whether the phone should vibrate
insistent : false, //> Whether the notification should be insistent
group : 'News', //> Name of group to group similar notifications together
localOnly : false, //> Whether this notification should be bridged to other devices
priority : +2, //> Notification priority, from -2 to +2
bigText : true,
//> Add LED flashing
ledOn : 200,
ledOff : 300,
backgroundOnly : false
}
Hi.
Currently using your module, but I'm unable to receive notifications when the app is closed.
When running all works fine, when closed I simply see nothing (but Android monitor reflects that is being called):
[INFO] : GCMIntentService: (IntentService[GCMIntentService--15]) [6,15635] Title: null
[INFO] : GCMIntentService: (IntentService[GCMIntentService--15]) [0,15635] Message: null
[INFO] : GCMIntentService: (IntentService[GCMIntentService--15]) [1,15636] Ticker: null
[WARN] : V8Function: Runtime disposed, cannot call function.
Why is all null? What I send from my server is this: {"android":{"alert": "Testing", "title": "My title", "message": "My message"}}
Can we upload compiled module file under Dist a directory. So, other can direct start using module.
Is there a way to show the notification on the screen,
and not only on the Notification Center?
Hello,
I am trying to making a demo with this module but am getting below error while compiling a demo project.
Please help me to solve this issue.
[ERROR] : TiApplication: (main) [58,1265] Sending event: exception on thread: main msg:java.lang.UnsatisfiedLinkError: dlopen failed: library "libstlport_shared.so" not found; Titanium 6.0.4,2017/04/26 14:02,undefined
[ERROR] : TiApplication: java.lang.UnsatisfiedLinkError: dlopen failed: library "libstlport_shared.so" not found
[ERROR] : TiApplication: at java.lang.Runtime.loadLibrary(Runtime.java:372)
[ERROR] : TiApplication: at java.lang.System.loadLibrary(System.java:1076)
[ERROR] : TiApplication: at org.appcelerator.kroll.runtime.v8.V8Runtime.loadExternalModules(V8Runtime.java:151)
[ERROR] : TiApplication: at org.appcelerator.kroll.runtime.v8.V8Runtime.initRuntime(V8Runtime.java:118)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollRuntime.doInit(KrollRuntime.java:205)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:114)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollRuntime.init(KrollRuntime.java:136)
[ERROR] : TiApplication: at com.mb.demofcm.DemofcmApplication.onCreate(DemofcmApplication.java:46)
[ERROR] : TiApplication: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
[ERROR] : TiApplication: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4741)
[ERROR] : TiApplication: at android.app.ActivityThread.access$1600(ActivityThread.java:153)
[ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1408)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:148)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5451)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Hi,
Thanks a lot for the module.
It is working great.
I am facing 2 issues here,
Your help is highly appreciated.
Not sure if something changed at googles side because I had that working a week ago and now I receive this message:
D/GCMIntentService(5503): (IntentService[GCMIntentService--2]) [8312,16380] Push notification received
W/Bundle(5503): Key google.sent_time expected String but value was a java.lang.Long. The default value <null> was returned.
W/Bundle(5503): Attempt to cast generated internal exception:
W/Bundle(5503): java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
W/Bundle(5503): at android.os.BaseBundle.getString(BaseBundle.java:923)
W/Bundle(5503): at nl.vanvianen.android.gcm.GCMIntentService.onMessage(GCMIntentService.java:98)
W/Bundle(5503): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
W/Bundle(5503): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
W/Bundle(5503): at android.os.Handler.dispatchMessage(Handler.java:102)
W/Bundle(5503): at android.os.Looper.loop(Looper.java:168)
W/Bundle(5503): at android.os.HandlerThread.run(HandlerThread.java:61)
D/GCMIntentService(5503): (IntentService[GCMIntentService--2]) [1,16381] Message key: "google.sent_time" value: "null"
W/Bundle(5503): Key google.sent_time expected String but value was a java.lang.Long. The default value <null> was returned.
W/Bundle(5503): Attempt to cast generated internal exception:
W/Bundle(5503): java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
W/Bundle(5503): at android.os.BaseBundle.getString(BaseBundle.java:923)
W/Bundle(5503): at nl.vanvianen.android.gcm.GCMIntentService.onMessage(GCMIntentService.java:106)
W/Bundle(5503): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
W/Bundle(5503): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
W/Bundle(5503): at android.os.Handler.dispatchMessage(Handler.java:102)
W/Bundle(5503): at android.os.Looper.loop(Looper.java:168)
W/Bundle(5503): at android.os.HandlerThread.run(HandlerThread.java:61)
E/AndroidRuntime(5503): FATAL EXCEPTION: IntentService[GCMIntentService--2]
E/AndroidRuntime(5503): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
E/AndroidRuntime(5503): at nl.vanvianen.android.gcm.GCMIntentService.onMessage(GCMIntentService.java:108)
E/AndroidRuntime(5503): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
E/AndroidRuntime(5503): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
E/AndroidRuntime(5503): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(5503): at android.os.Looper.loop(Looper.java:168)
E/AndroidRuntime(5503): at android.os.HandlerThread.run(HandlerThread.java:61)
It looks like this section:
https://github.com/morinel/gcmpush/blob/master/src/nl/vanvianen/android/gcm/GCMIntentService.java#L108
has to include a null check for value
Hi,
I want to show specific view when the user touches the notification. It works when the app is in foreground and background, but it doesn't when the app is closed (it only opens the app and). In the logcat I can't see it never entering in the lastData if, I don't know why.
Is there a way to achieve this?
Here is my code, anyway:
exports.pushNotification = function() {
var gcm = require("nl.vanvianen.android.gcm");
var registered = Titanium.App.Properties.getString('pushRegistered2') != null;
Ti.API.info('REGISTERED: ' + registered);
/* If the app is started or resumed act on pending data saved when the notification was received */
var lastData = gcm.getLastData();
if (lastData) {
Ti.API.info("Last notification received " + JSON.stringify(lastData));
// Here I try to show the view - it doesn't work
Ti.App.fireEvent('view:FavoriteView', {
push : lastData
});
gcm.clearLastData();
}
gcm.registerPush({
/* The Sender ID from Google Developers Console, see https://console.developers.google.com/project/XXXXXXXX/apiui/credential */
/* It's the same as your project id */
senderId : '299548822026',
notificationSettings : {
// sound : 'mysound.mp3', /* Place soudn file in platform/android/res/raw/mysound.mp3 */
// smallIcon : 'notification_icon.png', /* Place icon in platform/android/res/drawable/notification_icon.png */
// largeIcon : 'appicon.png', /* Same */
vibrate : true, /* Whether the phone should vibrate */
insistent : true, /* Whether the notification should be insistent */
group : 'MyNotificationGroup', /* Name of group to group similar notifications together */
localOnly : false, /* Whether this notification should be bridged to other devices */
priority : +2 /* Notification priority, from -2 to +2 */
},
success : function(event) {
Ti.API.info("Push registration success: " + JSON.stringify(event));
/* Add code to send event.registrationId to your server */
if (!registered) {
var myID = event.registrationId;
Titanium.App.Properties.setString("deviceToken", myID);
Alloy.Globals.utils.sendDeviceToken(Alloy.Globals.getUserId(), myID/*, Alloy.Globals.getPushRegisterURL(), _callbackSendServer*/);
Titanium.App.Properties.setString("pushRegistered2", "1");
}
},
error : function(event) {
Ti.API.info("Push registration error: " + JSON.stringify(event));
alert(event.error);
},
callback : function(event) {
Ti.API.info("Push callback = " + JSON.stringify(event));
/* Called when a notification is received and the app is in the foreground */
Alloy.Globals.lastPushMessage = event.data.message;
// Here I try to show the view - It works
Ti.App.fireEvent('view:FavoriteView', {
push : event.data
});
var dialog = Ti.UI.createAlertDialog({
title : 'Push received',
message : JSON.stringify(event.data),
buttonNames : ['View'],
cancel : 1
});
dialog.addEventListener("click", function(event) {
dialog.hide();
if (event.index == 0) {
/* Do stuff to view the notification */
}
});
//dialog.show();
}
});
};
My settings as below and working like a charm. But when I send more than one notification my remote server, Android 5.1 (this version is my phone version) shows only last notification. Where is my fault?
senderId : 'xxxxxx', //> It's the same as your project id
notificationSettings : {
sound : 'custom.mp3',
smallIcon : 'notification.png',
largeIcon : 'appicon.png',
vibrate : true,
nsistent : false,
group : 'JLB',
localOnly : false,
priority : +2,
bigText : true,
ledOn : 200,
ledOff : 300
}
And how can I clear my last notification data?
Tried compiling the module with 5.4.0, with minsdk set to 5.4.0 but still having the same issue.
The backgroundOnly
setting should only turn off system notifications, but should still send the data to the app's callback method for processing if the app is open. Currently, if backgroundOnly
is true, GCMIntentService.onMessage()
returns early if the app is in the foreground without sending the data to the GCMModule
.
Is it possible with this library to receive pushes when the app is closed and out of memory?
Can we receive and handle notifications when the app is closed?
Hi,
I tried to install the module through "Help" -> "Install Mobile Module" and it gets succesfully installed but it doesn't list in tiapp.xml. I tried with versions 1.6, 1.5 and 1.3. Thus, I can't compile the module.
Can someone help me? Provide me a link with a valid dist zip?
Platform: Android
Titanium SDK: 5.3.0.GA
Appcelerator Studio: 4.6.0.201605201934
Mac OS X El Capitan
Thank's
On Android 5.x and 6.x, but not 4.x, my app is opened automatically when the push message arrives without user interaction. How do I prevent this? I want the user to have to tap the message to open my app.
Is there perhaps a setting I should be using to control this? Here are my settings:
gcm.registerPush({
senderId: GCM_SENDER_ID, // my gcm sender id
notificationSettings: {
sound: Alloy.Globals.pushSoundsEnabled ? 'caralarm.wav' : undefined,
smallIcon: 'notification_icon.png',
largeIcon: 'appicon.png',
vibrate: true,
insistent: false,
group: 'ACVNotificationGroup',
localOnly: false,
priority: +2
},
success: deviceTokenSuccess,
error: deviceTokenError,
callback: receivePush
});
Hi, I have an error similar to this one: #1 but can not figure out where is my problem.
When app is closed notification do not show in statusbar.
this is the error in logcat:
D/GCMIntentService(24838): (IntentService[GCMIntentService--1]) [60,920] Push notification received
D/GCMIntentService(24838): (IntentService[GCMIntentService--1]) [6,926] Message key: payload value: {"android": {"title": "test petyk 10","alert": "test petyk 10","icon": "little_star","badge": 3,"sound": "door_bell","vibrate": true},"custom_field_1": "Push not Rocks!","custom_field_2": "Hi Push"}
D/GCMIntentService(24838): (IntentService[GCMIntentService--1]) [0,926] Message key: from value: xxxxxxxxx
D/GCMIntentService(24838): (IntentService[GCMIntentService--1]) [1,927] Message key: collapse_key value: collapse
D/Module (24838): Loading module: alloy -> Resources/alloy.js
D/GCMIntentService(24838): (IntentService[GCMIntentService--1]) [26,953] Message received but no message so will make this silent
i saw from this issue #1 that "message" property is needed and try with:
{"android": {"message": "test petyk 8", "title": "test petyk 8","alert": "test petyk 8","icon": "little_star","badge": 3,"sound": "door_bell","vibrate": true},"custom_field_1": "Push not Rocks!","custom_field_2": "Hi Push"}
and
{"android": {"title": "test petyk 8","alert": "test petyk 10","icon": "little_star","badge": 3,"sound": "door_bell","vibrate": true},"message": "test petyk 10", "custom_field_1": "Push not Rocks!","custom_field_2": "Hi Push"}
but still the same error appears in logcat.
Do you have any ideas what can be wrong
I am facing the same issue as described here on JIRA:
Has anyone experienced the same issue, but somehow managed to find a solution?
Hi, I tried to add new method at GCMModule.java
@Kroll.method
public void cancelNotificationById(int notificationId) {
try
{
NotificationManager notificationManager = (NotificationManager) TiApplication.getInstance().getApplicationContext().getSystemService(TiApplication.NOTIFICATION_SERVICE);
notificationManager.cancel(notificationId);
Log.i(LCAT, "kedi tebi");
} catch (Exception ex) {
Log.e(LCAT, "Cannot cancel notificationId: " + notificationId + " | " + ex.getMessage());
}
}
When I call from Appcelerator I am getting error like "GCM hasn o method" I am calling method as below
var gcm = require("nl.vanvianen.android.gcm");
gcm.cancelNotificationById(1);
Do you have any idea?
Thank you in advance.
Hi,
Could you please add LED light setting for the notifications.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.