You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
Using a callback after clicking the notification on Android #212
Please, tell us how to recreate the issue in as much detail as possible.
I am trying to invoke a callback function after the notification is been clicked (and the app is on background).
i used this code in order to get the notification from the intent like in the documentation:
application.on(application.resumeEvent, function (args) {
if (args.android) {
var act = args.android;
var intent = act.getIntent();
var extras = intent.getExtras();
if (extras) {
// console.dir(extras)
console.log(extras.keySet().toString());
for (var key in extras) {
console.log(key + ' --> ' + extras[key]);
...
instead of seeing keys related to the notification in the logs i see a list of methods:
JS: android.util.MapCollections$KeySet@cf2feb2f
JS: constructor --> function () { [native code] }
JS: <init> --> function <init>() { [native code] }
JS: clear --> function clear() { [native code] }
JS: clone --> function clone() { [native code] }
JS: describeContents --> function describeContents() { [native code] }
JS: getBinder --> function getBinder() { [native code] }
JS: getBundle --> function getBundle() { [native code] }
JS: getByte --> function getByte() { [native code] }
JS: getByteArray --> function getByteArray() { [native code] }
JS: getChar --> function getChar() { [native code] }
JS: getCharArray --> function getCharArray() { [native code] }
JS: getCharSequence --> function getCharSequence() { [native code] }
JS: getCharSequenceArray --> function getCharSequenceArray() { [native code] }
JS: getCharSequenceArrayList --> function getCharSequenceArrayList() { [native code] }
JS: getClassLoader --> function getClassLoader() { [native code] }
JS: getFloat --> function getFloat() { [native code] }
JS: getFloatArray --> function getFloatArray() { [native code] }
...
Is it what i'm supposed to see or something in my implementation isn't right?
I managed to fix it by using this code from the demo app.
application.on(application.resumeEvent, function (args) {
if (args.android) {
const act = args.android;
const intent = act.getIntent();
const extras = intent.getExtras();
console.log("Resuming activity");
if (extras) {
console.log("If your notification has data (key: value) pairs, they will be listed here:");
const keys = extras.keySet();
const iterator = keys.iterator();
while (iterator.hasNext()) {
const key = iterator.next();
console.log(key + ": " + extras.get(key).toString());
// clear the used keys in order to avoid getting them back
// when manually switching the application between background and foreground
intent.removeExtra(key);
}
}
}
});
Activity
tomshabtay commentedon Apr 16, 2018
I managed to fix it by using this code from the demo app.
zbranzov commentedon Apr 20, 2018
If you managed to fix the case would you close the issue?