OnMessage in GCMBaseIntentService method called multiple time? - android

I am doing sample PoC using GCM. I send the registration request to gcm server from my device and got the registration id for successful registration. I stored all the registration id in my app server database. I sent the data only one time to GCM from my app server to all my registration id. But, the OnMessage() method of GcmBaseIntentService called multiple time.
here is GCM response to my appserver when i am sending data
{
"multicast_id": 5986417894970376000,
"success": 7,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1355230384617663%9fa953f8f9fd7ecd"
},
{
"message_id": "0:1355230384617914%9fa953f8f9fd7ecd"
},
{
"message_id": "0:1355230384617911%9fa953f8f9fd7ecd"
},
{
"message_id": "0:1355230384617987%9fa953f8f9fd7ecd"
},
{
"message_id": "0:1355230384617909%9fa953f8f9fd7ecd"
},
{
"message_id": "0:1355230384617985%9fa953f8f9fd7ecd"
},
{
"message_id": "0:1355230384618032%9fa953f8f9fd7ecd"
}
]
}
I am doing some time taking task in my onMessage() method using AsynTask, Due to this multiple calls multiple thread getting created.
Please advice me on this issue.

The problem with my server side code. Single registration id added multiple times in devices list of my payload data.

Related

Huawei Push Kit API - Read data from payload of Notifications - onRemoteMessageReceived don't work

I want to read the date field from payload of this push notification but the api doesn't seem to work :(
I'm now from hms Huawei, i have read this tutorial:
HMS-Plugin-Guides-V1
all part is completed except d point, -> error of overwriting.
When i send a notification, and i push on it. All ok my app will open. But i can't read notification body.
In the log i see the notification service start -> take token and immediately kill itself... i don't understand where is problem.
Notify JSON
{
"validate_only": false,
"message": {
"notification": {
"title": "Notifica simpatica",
"body": "Io sono il body della notifica simpatica",
"notify_icon": "https://res.vmallres.com/pimages//common/config/logo/SXppnESYv4K11DBxDFc2.png"
},
"data": "{'param1':'value1','param2':'value2'}",
"android": {
"collapse_key": -1,
"urgency": "NORMAL",
"category": "PLAY_VOICE",
"ttl": "1448s",
"fast_app_target": 1,
"notification": {
"click_action": {
"type": 1,
"intent": "intent://eccc_ecc"
}
}
},
"token":-xxxxx"
]
}
}
My app code:
const App = () => {
HmsPushEvent.onTokenReceived(result => {
console.log('Push token', result.token);
});
HmsPushEvent.onRemoteMessageReceived(event => {
console.log('Data message received');
const RNRemoteMessageObj = new RNRemoteMessage(event.msg);
const msg = RNRemoteMessageObj.parseMsgAllAttribute(event.msg);
console.log('Data message received : ' + msg);
});
return (
<SafeAreaView>
<Text>Testing Text</Text>
</SafeAreaView>
);
};
Manifest (only application section, other line is standard for any android app):
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data
android:name="push_kit_auto_init_enabled"
android:value="true" />
</application>
this is 'condensed' log:
16:23:53.989 HMSSDK_HmsMessageService: start to bind
16:23:54.032 HMSSDK_HmsMessageService: handle message start
16:23:54.036 HMSSDK_HmsMessageService: onNewToken
16:23:54.043 HMSSDK_HmsMessageService: doOnNewToken:transactionId = null , internalCode = 0,subjectId:null,proxyType:null
16:23:54.046 HMSSDK_HmsMessageService: Apply token OnNewToken, subId: null
16:23:54.179 HMSSDK_HmsMessageService: onNewToken to host app.
16:23:54.215 HMSSDK_HmsMessageService: onNewToken to host app with bundle.
16:23:54.222 HMSSDK_HmsMessageService: start to destroy
You are trying to send a Notification messages, but onRemoteMessageReceived is used to receive a data message, so you cannot read the date field.
User-defined fields of notification messages are transferred to the app when a user clicks a message and need to be received through the HmsPushEvent.onNotificationOpenedApp(callback).
For more details, pls kindly refer to this interface documents.

Custom notification sound in background(Firebase Android)

I use Firebase for notification in my Android application and try create custom sound for notification in background. Client app doesn't handle notifications, only android system. Notifications are sent from backend. Json structure:
{
"message": {
"token": "e1IMKJe...",
"notification": {
"title": "Test",
"body": "Test message from server"
},
"android": {
"notification": {
"sound": "sound_base_notification",
"channel_id":"test_chanel_id"
}
}
}
}
In method onMessageReceived, I obtained response like this:
Bundle[{google.delivered_priority=normal, google.sent_time=1596444752253, gcm.notification.android_channel_id=chanel_id_test,
google.ttl=23746652,
google.original_priority=normal,
gcm.notification.e=1,
gcm.notification.sound=default,
gcm.notification.title=Test,
from=763552563,
gcm.notification.sound2=sound_base_notification,
google.message_id=0:1596...,
gcm.notification.body=Test message from server,
google.c.a.e=1,
google.c.sender.id=29852264618,
collapse_key=com.test}]
Could you help me understand where does the gcm.notification.sound2 come from although in json push exsist onle single key sound?
Note: Was testing on Android 10

Topics Subscriptions not active on new token

We are planning on migrating to using topics through FCM for our application.
I have done some tests and have noticed a weird behaviour (looks very much like a bug).
When receiving a new token for the same InstanceID the https://iid.googleapis.com/iid/info/ endpoint still shows previously active topic subscriptions for this instance id.
But notifications sent to this topic do not arrive on the device.
These are the steps I took:
Get a token in the Android SDK
FirebaseInstanceId.getInstance().getToken(projectId, scope) => ABC:123
Subscribe to a topic in the Android SDK
FirebaseMessaging.getInstance().subscribeToTopic(topicName)
Verify the topic was subscribed to using the API call: https://iid.googleapis.com/iid/info/ABC:123?details=true
{
"applicationVersion": "1",
"connectDate": "2019-02-18",
"attestStatus": "UNKNOWN",
"application": "com.foo.bar",
"scope": "*",
"authorizedEntity": "12345",
"rel": {
"topics": {
"topicName": {
"addDate": "2019-02-18"
}
}
},
"connectionType": "WIFI",
"appSigner": "XXXXXXX",
"platform": "ANDROID"
}
Send a notification to the topic => notification arrives
Delete the token in the Android SDK
FirebaseInstanceId.getInstance().deleteToken(projectId, scope)
Get a new token in the Android SDK
FirebaseInstanceId.getInstance().getToken(projectId, scope) => ABC:456
Verify the topic was subscribed to using the API call: https://iid.googleapis.com/iid/info/ABC:456?details=true
{
"applicationVersion": "1",
"connectDate": "2019-02-18",
"attestStatus": "UNKNOWN",
"application": "com.foo.bar",
"scope": "*",
"authorizedEntity": "12345",
"rel": {
"topics": {
"topicName": {
"addDate": "2019-02-18"
}
}
},
"connectionType": "WIFI",
"appSigner": "XXXXXXX",
"platform": "ANDROID"
}
Just to verify this is the new response for the deleted token.
https://iid.googleapis.com/iid/info/ABC:123?details=true
{ "error": "No information found about this instance id." }
Send a notification to the topic => notification does not arrive!
This behavior does not restore. (We waited a full day).
Why does the info endpoint show that the new token was subscribed to the topic, but in reality is not registered at all?
The only fix seems to be re-subscribing the new token on the topic.
Thanks in advance.

Google Drive Push notification for android is it works with appengine as domain

Is it possible that push notification on Android of google drive works
If I make AppEngine project which i registered as domain.
code not working
Drive.Changes.List request1 = mService.changes().list(startpageToken);
ChangeList changes1 = request1.execute();
Channel channel = new Channel();
channel.setId(UUID.randomUUID().toString());
channel.setType("web_hook");
channel.setAddress("https://ggledrvsrvcaccnt.appspot.com/hello");
System.out.println(" **channel
Id"+channel.getId()+"paggtoken"+startpageToken);
Channel c = mService.changes().watch(startpageToken,
channel).execute();
System.out.println("ResourceId"+c.getResourceId());
System.out.println("Kind"+c.getKind());
System.out.println("resuri"+c.getResourceUri());
System.out.println("token"+c.getToken());
System.out.println("expi"+c.getExpiration());
output is
**channel Iddce0eb26-e23d-43f8-a50b-a68aee2aa286paggtoken508
ResourceId nT5QxvC2hKhVrDdPn61i5H6Jr10
Kind api#channel
resuri https://www.googleapis.com/drive/v3/changes?includeCorpusRemovals=false&includeRemoved=true&includeTeamDriveItems=false&pageSize=100&pageToken=508&restrictToMyDrive=false&spaces=drive&supportsTeamDrives=false&alt=json
token null
expi 1493122880000
But still not able to get notification on status bar
If i check in api explorer
All Versions > Drive API v3 > drive.changes.watch
{
"error": {
"errors": [
{
"domain": "global",
"reason": "push.webhookUrlUnauthorized",
"message": "Unauthorized WebHook callback channel:
https://ggledrvsrvcaccnt.appspot.com/hello"
}
],
"code": 401,
"message": "Unauthorized WebHook callback channel:
https://ggledrvsrvcaccnt.appspot.com/hello"
}
}
Please Let me know Am I on wrong track
For checking Notification that is information in notification
which event or service to invoke in android code..

Authentication Error on Select Android Devices

We are running MobileFirst Consumer Edition 7.0 We have a Liberty Server.
A majority of our users are able to successfully authenticate using our Mobile App with a AD Login.
A few users have reported that the log in hangs. Some other relevant information: the users who have experienced this issue are using Android 5.0.2. I can log in as them on other versions of Android without any problem. (I personally haven't been able to duplicate this). When they log in, I am seeing this error in the logs when the login hangs. What could be the issue? If you need additional logs or a copy of the code, I can supply that via email. I just do not wish to disclose full logs here.
{
"message": "Session ended for user \u0027REMOVED\u0027",
"level": "INFO",
"source": "server",
"threadId": 52,
"loggerName": "com.worklight.core.util.AuditBean",
"timestamp": "25-08-15 10:50:45:320"
},
{
"message": "Session ended for user \u0027REMOVED\u0027",
"level": "INFO",
"source": "server",
"threadId": 52,
"loggerName": "com.worklight.core.util.AuditBean",
"timestamp": "25-08-15 10:42:27:321"
},
{
"message": "FWLSE0048E: Unhandled exception caught: java.util.NoSuchElementException\ncom.worklight.gadgets.GadgetRuntimeException: java.util.NoSuchElementException\n\tat com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfoStandard(GadgetAPIRequestCoder.java:408)\n\tat com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfo(GadgetAPIRequestCoder.java:236)\n\tat com.worklight.gadgets.utils.GadgetUtils.getApplicationEnvironmentFrom(GadgetUtils.java:225)\n\tat com.worklight.core.auth.impl.AuthenticationFilter.isDeviceDisabled(AuthenticationFilter.java:535)\n\tat com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:186)\n\tat com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:975)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1097)\n\tat com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)\n\tat com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:912)\n\tat com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)\n\tat com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:938)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\n\tat java.lang.Thread.run(Thread.java:722)\nCaused by: java.util.NoSuchElementException\n\tat java.util.StringTokenizer.nextToken(StringTokenizer.java:349)\n\tat com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfoStandard(GadgetAPIRequestCoder.java:367)\n\t... 15 more\n [project MyGPCMobile]",
"sourceClass": "com.worklight.core.auth.impl.AuthenticationFilter",
"sourceMethodName": "doFilter",
"throwable": {
"message": "java.util.NoSuchElementException",
"stacktrace": [
"com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfoStandard(GadgetAPIRequestCoder.java:408)",
"com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfo(GadgetAPIRequestCoder.java:236)",
"com.worklight.gadgets.utils.GadgetUtils.getApplicationEnvironmentFrom(GadgetUtils.java:225)",
"com.worklight.core.auth.impl.AuthenticationFilter.isDeviceDisabled(AuthenticationFilter.java:535)",
"com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:186)",
"com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)",
"com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)",
"com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:975)",
"com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1097)",
"com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)",
"com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:912)",
"com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)",
"com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:938)",
"java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)",
"java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)",
"java.lang.Thread.run(Thread.java:722)"
]
},
"level": "SEVERE",
"source": "server",
"threadId": 196547,
"loggerName": "com.worklight.core.auth.impl.AuthenticationFilter",
"timestamp": "25-08-15 10:40:07:590"
},
{
"message": "Session started for user \u0027REMOVED\u0027",
"level": "INFO",
"source": "server",
"threadId": 191685,
"loggerName": "com.worklight.core.util.AuditBean",
"timestamp": "25-08-15 10:39:43:905"
},
{

Categories

Resources