Google GCM - 未在android棒棒糖中接收推送通知 [英] Google GCM - Not receiving push notifications in android Lollipop

查看:219
本文介绍了Google GCM - 未在android棒棒糖中接收推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的android应用程序中,我使用GCM从我的公司服务器接收消息。

我编写了c2dm的代码,并按照说明将代码迁移到GCM。 ( http://developer.android.com/google/gcm/c2dm.html



在Android棒棒糖(Nexus 9 wifi)中,设备注册推送通知并接收推送注册ID,但是当我从我的服务器发送消息时, t

在以前的Android版本中(从4.0到4.4),我没有任何问题。



<您知道棒棒糖的推送通知有任何问题吗?



谢谢 解决方案我们在办公室遇到了同样的问题,这就是为什么我在这里偶然发现了你的帖子。我测试了三个独立的Nexus 9设备(仅WiFi),并且在每种情况下,所有这些设备都成功注册了推送...但从未收到从服务器发送的任何通知。

我做的第一个测试使用了我们现有的android应用程序和服务器。在此失败后,我下载了推送通知测试来自Google Play商店。这在其他设备(Nexus 5等)上完美运行,但未能在Nexus 9上收到通知。



只是为了解决可能的问题Play Store测试应用程序已过期,我创建了一个测试Android应用程序和服务器脚本,以查看是否可以进一步缩小问题范围。我遇到了同样的问题。除Nexus 9注册和接收的推送通知外,我测试的每个设备。我尝试了改变项目中Google Play服务库的版本(从最新版本到最新版本),但是没有任何效果。

对于我上面提到的最后一次尝试,我使用了这里找到的GCM演示应用程序:

<$ p $ rel =nofollow> GCM客户端
以及一个基于另一个用户代码修改的php脚本p> <?php

$ nexus5 ='';
$ nexus9 ='';
$ nexus9Alt ='';
$ registrationIds = array($ nexus5,$ nexus9,$ nexus9Alt);

$ apiKey ='';

$ msg =数组

'message'=>'你知道嗅到岩石在做什么吗?',
'title'=> 'Push Test',
'subtitle'=>'This is a subtitle',
'tickerText'=>'This is the ticker',
'vibrate'=> 1 ,
'sound'=> 1
);

$ fields = array

'registration_ids'=> $ registrationIds,
'data'=> $ msg
);

$ headers = array

'Authorization:key ='。$ apiKey,
'Content-Type:application / json'
);

$ ch = curl_init();
curl_setopt($ ch,CURLOPT_URL,'https://android.googleapis.com/gcm/send');
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));
$ result = curl_exec($ ch);
curl_close($ ch);

echo $ result;

更新:我们将办公室中的三个平板电脑更新为5.0.1 OTA,而平板电脑仍然不会收到推送通知。这些都没有谷歌的消息,但希望它会在下一个OTA中得到修复。

更新:1月13日,我们注意到Nexus 9开始接收推送通知。显然谷歌修复了它。圆圈是完整的。


In my android application I use GCM to receive message from my company server.

I wrote the code for c2dm and I followed the instructions for migrating the code to GCM. (http://developer.android.com/google/gcm/c2dm.html)

In android Lollipop (Nexus 9 wifi), the device registers for push notifications and receives the push registration id, but when I send a message from my server, in the device I don't receive any message.

In previous android versions (from 4.0 to 4.4) I haven't any problems.

Do you know of any problems in push notifications of Lollipop?

Thanks

解决方案

We encountered the same problem in our office, which is why I stumbled upon your post here. I've tested three separate Nexus 9 devices (WiFi Only), and in each case all of them successfully registered for push...but never receive any notifications that are sent from the server.

The first test I did used our existing android application and server. After this was unsuccessful I downloaded Push Notification Test from the Google Play Store . This worked flawlessly on other devices (Nexus 5...etc), but failed to receive notifications on the Nexus 9.

Just for the sake of a possible issue with the Play Store Test application being out of date, I created a test Android application and server script to see if I could narrow the problem down further. I encountered the same issue. Every device I tested with the exception of the Nexus 9 registered and received push notifications. I tried varying the version of the Google Play Services library in the project (from newest to a few versions back), but that had no effect.

For my last attempt mentioned above I used the GCM demo application found here: GCM Client along with a php script I modified based on another user's code (with keys and reg id's removed obviously):

<?php

$nexus5 = '';
$nexus9 = '';
$nexus9Alt = '';
$registrationIds = array($nexus5,$nexus9,$nexus9Alt);

$apiKey = '';

$msg = array
(
    'message'       => 'Do you know smell what the rock is cooking?',
    'title'         => 'Push Test',
    'subtitle'      => 'This is a subtitle',
    'tickerText'    => 'This is the ticker',
    'vibrate'       => 1,
    'sound'         => 1
);

$fields = array
(
    'registration_ids'  => $registrationIds,
    'data'              => $msg
);

$headers = array
(
    'Authorization: key=' . $apiKey,
    'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
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 ) );
$result = curl_exec($ch );
curl_close( $ch );

echo $result;

Update: We updated the three tablets in office to the 5.0.1 OTA, and the tablets still will not receive push notifications. No news from google on these either, but hopefully it will be fixed in the next OTA.

Update: On January 13th we noticed that the Nexus 9's started receiving push notifications. Apparently Google fixed it. The circle is complete.

这篇关于Google GCM - 未在android棒棒糖中接收推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆