简体   繁体   English

未收到Android推送通知

[英]Android Push Notification not being received

I am following the tutorial of GCM given here on AndroidHive . 我正在关注AndroidHive上的GCM教程。 Everything is same except I am using my own Sony Xperia L instead of any emulator. 除了我使用自己的Sony Xperia L而不是任何仿真器之外,其他所有内容都相同。 I am able to register my device on my database. 我可以在数据库中注册设备。 However, Google's API console is not showing any change after registration. 但是,Google的API控制台在注册后不会显示任何更改。 Here is the screen I am getting before and after registration. 这是注册前后我得到的屏幕。 API屏幕

I am immediately getting a blank notification (with no data or text) on my cell just after registration. 注册后,我立即在单元格上收到空白通知(无数据或文本)。 But whenever I try type and send a notification from the web interface built during the tutorial, the page gets refreshed without showing any error, but no notification arrives on my cell. 但是,每当我尝试从教程中构建的Web界面键入并发送通知时,页面都会刷新而不会显示任何错误,但是没有通知到达我的单元格。

Please help me solve this problem. 请帮我解决这个问题。 I want to manage push notifications based on users in my MySQL database. 我想基于MySQL数据库中的用户来管理推送通知。 If any similar descriptive tutorial explains the same, it will be very much helpful to me. 如果有任何类似的描述性教程对此进行了解释,则对我很有帮助。 Thanks :) 谢谢 :)

I also faced the same problem in the beginning but then it was solved. 一开始我也遇到了同样的问题,但是后来解决了。 Make sure that your computer from which u are sending the notification and the device are connected to the same wifi. 确保您要从其发送通知的计算机和该设备已连接到同一wifi。 Also if ur using WAMP, make sure that 'PHP Curl' is enabled. 另外,如果您使用WAMP,请确保已启用“ PHP Curl”。

I used my own php script to contact GCM server Instead of the interface index.php given in tutorial. 我使用了自己的php脚本来联系GCM服务器,而不是教程中给出的接口index.php

<?php    
    include_once './GCM.php';

    $gcm = new GCM();

    $registatoin_ids = array("my_reg_id_here");
    $message= "Wow! a noti!";
    $message = array("price" => $message);

    $result = $gcm->send_notification($registatoin_ids, $message);

    echo $result;
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM