google-cloud-messaging

How to detect if your android app is in the foreground (API 21)

只谈情不闲聊 提交于 2019-12-21 22:11:23
问题 when receiving a GCM message, the behaviour of my app depends on if it is in the foreground or not. Prior to API 21 I used the following: Boolean onForeground = this.getPackageName().equalsIgnoreCase( ((ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE)) .getRunningTasks(1).get(0).topActivity.getPackageName() ); Now getRunningTasks() is deprecated and behaving differently on API 21, what would be the best way on API 21 to detect if my app is in the foreground? Google recommends

Cordova PushPlugin: Android won't play push sound while app not running

大憨熊 提交于 2019-12-21 21:18:14
问题 I'm using the PushPlugin for cordova, and in android, I can't make the push notification play a sound while the app is not running or in background (the banner in status bar is presented ok). Here's the function that gets called on android push notifications- function onNotification(e) { . . . case 'message': { var myMedia = new Media("/android_asset/www/res/raw/tritone.mp3"); myMedia.play({ numberOfLoops: 2 }) the sound plays fine while app is running in foreground. This is the 'e' param

I cannot receive any FCM message anymore in background application

我的未来我决定 提交于 2019-12-21 20:54:28
问题 I cannot receive any data message anymore in my application when it's in background. Notice that it worked perfectly in my application until very recently. Maybe it stopped working after recent updates in my development environment, I can't say.... So I tried to make the test with the quickstart-android project, to see it works better. And the answer is no! I have no doubt that quickstart-android project is well configured to use FCM capabilities... I send the following message from Advanced

Push notification using jar is not working

南笙酒味 提交于 2019-12-21 20:49:24
问题 First of all please don't make this question as duplicate or anything else because all other don't cover my issue . I have an issue with push notification . I have implemented push notification in my app using gcm and make a jar with its source code. Now I have distributed it with my res folder for integration. Its working fine if host app don't implement push notification its own. If host app implement push notification its own then my integrated app doesn't receive push. I went through this

GCM is not working on Kindle fire devices: java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf

﹥>﹥吖頭↗ 提交于 2019-12-21 20:34:48
问题 Its throwing exception while calling GCM.register(this,SENDER_ID); java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf What is alternative option of GCM on Amazon devices? 回答1: Kindle Fire don't have "Google Play Services" library installed, so GCM won't work. Try ADM instead. 回答2: GCM have some limitation, In android device must have google play store, second one is android device configure with google account (This limitation in some devices.). You

GCM curl operation time out

痴心易碎 提交于 2019-12-21 17:28:26
问题 I have a couple of php files responsible for GCM operations stored on my server, they seem to work just fine when they want to but they often return an error that states: Curl error: Operation timed out after 0 milliseconds with 0 out of 0 bytes received Is this is a problem with the server or a problem with my GCM code? Below is my php file: <?php $message = urldecode($_POST['message']); $order = urldecode($_POST['order']); $registrationIDs = urldecode($_POST['registrationIDs']); $apiKey =

Should I call WakeLock before creating a notification?

拟墨画扇 提交于 2019-12-21 17:05:58
问题 I'm adding notifications to an Android app and only have the emulator to test with at the moment. When a notification is received, my onMessage() method in my GCMBaseIntentService subclass (GCMIntentService) is called. From here I create a notification to appear. If I turn the emulator on standby, no notification is seen (I do t know if it would be heard on a device?). So should I be calling WakeLock to wake the device before creating the notification? Thanks 回答1: I'm not sure if the emulator

Broadcast a notification to all registered devices

痞子三分冷 提交于 2019-12-21 16:53:10
问题 I'm trying to add push notification using Google Cloud Messaging to my Android application. I don't need anything fancy, I just want to notify all users of the app when certain events happen. I don't need to notify individual users, I always want to send the notification to every user. This is an internal app with a very limited number of users, it is not distributed publicly. Now, as far as I understand the documentation I need a registration id for every notification I want to send. I don't

Handling Push Notification scenarios on iOS and Android

可紊 提交于 2019-12-21 12:18:18
问题 I want to implement Push Notification for an App (both iOS and Android) and need clarifications on the following scenarios. I understand how the Push Notification works in general and the limitations. I did read the docs but that just got me confused and didnt answer all my questions. How are the following scenarios handled in iOS and Android: When the device is turned off When the device is not connected to 3G or Wifi networks When the device has crashed and need restart When the App is in

Push not received when app is killed

非 Y 不嫁゛ 提交于 2019-12-21 12:15:32
问题 I am using the new FCM to push message from my server to my android app. { "to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...", "data" : { "Nick" : "Mario", "Room" : "PortugalVSDenmark" } } I am able to push messages to my app using the new FCM however, when I kill the app (long press on home button then slide the app to the left), push messages are not delivered any more. Why? 回答1: Check the raw payload, what is received from server. body and title key have to have under notification key to get