I put in reference this Link
I implemented it it works but am facing troubles:
first sometimes I need to restart the android emulator so the push notification could be delivered when the emulator is restarted the push notification work properly.
after a while the push notification does not work and it need about 15 min to the push notification to get delivered. if I restart the emulator the push notifications get delivered and so on...
what do you think the problem here?
Its your wifi router probably, check the description here
https://play.google.com/store/apps/details?id=com.andqlimax.pushfixer
I opened an issue to google here:
https://productforums.google.com/forum/#!category-topic/nexus/connecting-to-networks-and-devices/fslYqYrULto
and they agree there is a TCP timeout on some conditions.
if you are expecting a notification but there a huge delay in android emulator.
You can perform following step to get instant notification.
Turn off the mobile data in Emulator then turn it on again, you will get the notification as soon as you turn it on
hope this helps :)
Related
I got some problem to share with, I've been testing push mobile notification via AWS-SNS push noti service and it works properly when my app is on foreground or background my notification almost come instant time after publishing but, there are some cases that may bug my app/works.
When my app had been killed from foreground or no interaction with my phone for a while(around minutes), notification that was sent from SNS then to FCM got delay and sometimes It required opening(wake up screen) mobile then notification will show up after that. This was weird and interesting at the same time.
What I have done so far:
I come through fcm doc spec - setting high priority to my noti message then my payload look likes,
{"data":{"payload":{}}, "priority":"high", "android":{"priority":"high"}}
I've set priority key to follow legacy HTTP API and HTTP v1 API already(Yes, I test with both cases) but, the behavior still got an issue
***I tested on Huawei phone, Android 8.0.1
NOTE: For APN, IOS works properly and I am so new to mobile dev so, feel free to suggest anything to me
Thank you in advance.
With a fresh install app on my Samsung Note 5 device and also on my emulator, some notifications was sent via the Firebase console are received properly on those 2 devices.
But after a day, my emulator was reopened, my phone was reconnected to the Wifi, I started creating some few notification messages on Firebase console again, but those devices did not receive any message from Firebase.
I turned off and turned on my phone's Wifi, then the phone received those notifications. I turned on and turned off plane mode on my emulator, then the emulator received those notifications. Is there something wrong with my app? Or with Firebase? (I already use WAKE_LOCK permission). Any suggestion?
Thanks!
It seems to work fine now after I changed my device's Wifi connection.
From #AL's comment:
There might be a chance that the Android device is connected to the
Wifi, but your Wifi needs something like a refresh for the internet
connection to work again, which is the same case for the devices
connected to it.
I still not sure why, but his comment make this works.
Great to know that, #AL gave a hint of the problem and you got it working too. I'm here for putting some of my thoughts here regarding your issue.
As you've worked with push notification already, I think you know pretty much about how this works actually. If you want a short brief, you might take a look at this answer.
Now, you already have known, you need to get a push registration ID from FCM when your application starts. This push registration ID, is the unique ID by which FCM knows when and how to send you a push notification. This push registration ID doesn't change every time you launch your application, but yes, it changes some times. When your push registration ID has been changed, but you couldn't get your new push registration ID from FCM, the push notification won't work properly in that time. This is usually a network issue though, but don't panic if that happens.
Another thing I need to point out is, push notification is not always guaranteed to be received in your device/devices. So if you're performing some action when a push notification is received in your application, you might need to make the action fail safe too (e.g. you might consider polling after a certain time if no push is received).
I have setup Push notifications in my Worklight 6.3 hybrid app which was working fine in my Android device until few days back. I didn't make any changes to the app after that. Now when I try to send notification, I get the result as '{"isSuccessful":true,"result": "Notification sent to user :: admin"}'.
Neither do I see notifications on my device, nor I see any error messages. I also get the 'onSuccess' callback called when WL.Client.Push.subscribe API is executed
From your description its seems like the message is sent to GCM and the
question we need to ask is why it's not arriving the device.
1)Can you please reinstall the application and then try to send push notification?
If it will work you may have a problem with the device subscription.
2)can you paste here the logcat - maybe we can find something there...
3)Did you try to receive the push when the phone is on WiFi?
If possible please try to check it on a different network.
Sometimes GCM is slow and you might get a notification after about 5 to 10 mins.
if we get isSuccessful":true,"result": "Notification sent to user :: admin
then from worklight end we have done everything right and GCM has also accepted the notification to be sent.
I will know more once you will upload the additional information
On the server side, I am using GCM server 1.0.2 library provided by Google. On the client side, I set up GCM as provided on the official documentation.
My problem is that everything works fine on most devices, but on few devices, push is not recieved.
if (case1)
message = new Message.Builder()
.timeToLive(0)
.collapseKey("0")
.delayWhileIdle(false)
.addData("msg", msg).build();
else if (case2)
message = new Message.Builder()
.collapseKey("2")
.addData("msg", msg).build();
else
message = new Message.Builder().addData("msg", msg).build();
Result result = sender.sendNoRetry(message, regId);
System.out.println("Message ID:"+result.getMessageId());
System.out.println("Failed:" + result.getErrorCodeName());
From what I can see from tests with the above code, there are no error. The message id is present, but error code name is null(which is a sign of successful push).
I've tried almost every setting. Tested with TTL, collapse key, delay while idle set on and off.
What are some cases that can cause to block(?) GCM push? And how can I resolve this?
EDIT
I have no idea why but the temporary solution below solved my problem.
In GcmIntentService#onHandleIntent just remove
GcmBroadcastReceiver.completeWakefulIntent(intent);
This line releases the wakeful service. I am curious though because on other devices, push messages are sent continuously even when this line was not removed.
This is not a solution because this document states that I should call completeWakeFulIntent after each work. Also, my method will drain the battery significantly.
Any suggestion?
Make sure you've set your SENDER ID you've received from Google correctly.
Make sure your device was registered with Google's GCM service correctly.
Make sure you are sending the push to the correct reg id you've received from Google. and that you didn't receive an error from Google GCM service.
Have you set the delay_while_idle = 1? This means the message won't reach the device if it's idle (off, offline, locked screen, etc...). Change it to delay_while_idle = 0 if you want your wakelock permission to make any difference. Please read more here.
Some times it takes time for the push to arrive (but never too much time, then there is a problem). Check what's the "time to live" of the push you've sent.
Do you have the correct version of the Playstore to receive the notification ?
Are you logged with a functional Google Account on those devices ?
I also had a problem when I "Force stop" an app, you can't receive notification on any app after a "force stop" (start with android 3.1) so be careful with that too.
if you are using wifi, may be the internet firewall block the gcm. try to use internet with your mobile sim card.
Checklist
Make sure Google Play Store is updated to latest version
Make sure there are no systemwide settings for notifications which are blocking
Go into app in Application Manager and uncheck/recheck 'Notifications'
If on Wifi, switch Wifi connection to a different AP (if possible)
Reboot the device
Install 'Push Notification Fixer' (install this anyway)
First-run notification setup can be annoyingly arbitrary and require the device be 'kicked' in one or more of these ways.
Is there any way to check/manage the push notifications (C2DM or from other service) is available for the Android phone or its based on application to application and have to manage in application only.
Regards,
Android_IT
If your push messages are wap push messages and they are not from your facebook/gmail account, it definitely comes from your other installed application. To detect from which application it comes from just install free app called Airpush detector and detect which apps send push messages and uninstall them.
Here is link for Airpush dector
Yes you can disable it..
Let me explain how? When you want push notification from server then you have to register your device. So same as there is option ofunregisteredif you do not want push notification anymore.So simply check if your device is already registered then unregistered your device.
But next and most important thing which i think you want. In android device there is not option explicitly to stop push notifications.So you have to implement by using code.
On this topic many people have discuss so i am giving you reference.Go through it May this help you
Click me for more help
i too have been receiving annoying push messages on my samsung galaxy s7562. what i did to stop it... i just go to the messaging-settings-push message settings and i simply unchecked the "receive push message from network"...hope this will help.