如何发送高优先级GCM?

问题描述 投票:14回答:3

我正在使用带有Android M Preview的Nexus 5。

我试图解决的问题是:

除非您的应用收到高优先级的Google云消息传递,否则会禁用网络访问权限。

我在做的是:

我把手机置于打盹模式,然后我发送一个优先级值为10的推送通知,我希望能在短时间内访问互联网,但这不起作用。

我应该使用其他类型的通知吗?有没有可用的文件?

谢谢。

Android M改变:https://developer.android.com/preview/behavior-changes.html

我发现了有关GCM优先级消息的信息:https://developers.google.com/cloud-messaging/server-ref

android google-cloud-messaging android-6.0-marshmallow
3个回答
8
投票

将优先级设置为10是正确的做法,但它不适用于在I / O上发布的Android M版本。它已得到修复,优先级10消息将在公开发布时按预期工作。


2
投票

https://developers.google.com/cloud-messaging/concept-options?hl=en#setting-the-priority-of-a-message

事实上,它与Google Play服务版本有关,而与Android版本无关。使用“高”作为优先级。


0
投票

只需将其添加到您的文件(.php,.jsf等):

$fields = array(
                    'registration_ids' => $android,
                    **'priority' => 'high',**
                    'data' => array( 'message' => $message,
                                     'title' => $title,                                 
                                     'created_at' => $created_at,                                
                                     'is_background' => $is_background,
                                     'pantallaMostrarPushAndroid' => "pushNotificationNormal")
                ); 

                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

                // Execute post
                $resultAndroid = curl_exec($ch);
© www.soinside.com 2019 - 2024. All rights reserved.