Php GCM消息是';当我的应用程序关闭时,不会进入我的应用程序
当我的应用程序关闭或从缓存中清除时,我想向用户显示我的GCM通知,下面是我的代码,它仅在应用程序打开但不在后台运行时工作:Php GCM消息是';当我的应用程序关闭时,不会进入我的应用程序,php,android,json,google-cloud-messaging,android-5.0-lollipop,Php,Android,Json,Google Cloud Messaging,Android 5.0 Lollipop,当我的应用程序关闭或从缓存中清除时,我想向用户显示我的GCM通知,下面是我的代码,它仅在应用程序打开但不在后台运行时工作: public function send_notification($registatoin_ids, $message) { include_once 'dbconfig.php'; // Set POST variables $url = 'https://android.googleapis.com/gcm/send'; $fields
public function send_notification($registatoin_ids, $message) {
include_once 'dbconfig.php';
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registatoin_ids,
'data' => $message,
);
智能手机在我的应用程序中看不到任何服务。下面是一个屏幕截图,您可以将我的应用程序与whatsapp等其他应用程序进行比较:
以下是我关于GCM的清单部分:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.app.path" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- ... other permissions -->
<permission
android:name="my.app.path.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="my.app.path.permission.C2D_MESSAGE" />
<application
...>
<!-- ... activites... -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="my.app.path" />
</intent-filter>
</receiver>
<service
android:name=".MyGcmListener"
android:exported="false"
android:enabled="true" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
</application>
</manifest>
我想显示whatsApp之类的通知。您是否尝试过在发送邮件时设置优先级
设置为
High priority
,允许GCM服务在可能的情况下唤醒休眠设备,并打开与应用程序服务器的网络连接。例如,具有即时消息、聊天或语音呼叫警报的应用程序通常需要打开网络连接,并确保GCM毫不延迟地将消息发送到设备。仅当消息时间紧迫且需要用户立即交互时,才设置高优先级,并注意将消息设置为高优先级比正常优先级消息更容易消耗电池。1)迁移到FCM 2)读取没有FCM是否可能?我不知道关于FCMcheck的任何事情所有类型的用户权限和使用此链接的权限我已经尝试了此解决方案,在发送消息时设置高优先级选项,但它没有解决我的问题