在模拟器中创建谷歌GCM测试应用程序并使用PHP获取注册ID(Create google GCM testing app in emulator and get registration id usi

编程入门 行业动态 更新时间:2024-10-23 23:22:46
在模拟器中创建谷歌GCM测试应用程序并使用PHP获取注册ID(Create google GCM testing app in emulator and get registration id using PHP)

我正在尝试创建一个将在模拟器上运行的测试应用程序,GCM服务器将使用PHP。

我正在查看代码如何将消息推送到目标设备,以下代码我在某处下载:

<?php $json = array(); $regId = $_GET["regID"]; $msg = $_GET["msg"]; if (isset($regId) && isset($msg)) { require_once("GCM.php"); $message = array("message" => $msg); $regId = explode(",", $regId); $result = gcm_push_notification($regId, $message); $success_code = json_decode($result,true)["success"]; if($success_code > 0){ //echo $result; // echo $success_code."/".count($regId); // }else{ echo "error"; } } else { echo "error"; } ?>

每次代码都需要“注册ID”来发送消息:

我想知道如何在发送消息之前每次都获得所有注册ID? 如果我创建一个仅在模拟器上运行的简单应用程序,它是否会生成注册ID? 我怎么做到的?

I'm trying to create a testing app which will run at emulator and the GCM server will use PHP.

I'm looking the code how it pushes the message to target device, the following code I downloaded somewhere:

<?php $json = array(); $regId = $_GET["regID"]; $msg = $_GET["msg"]; if (isset($regId) && isset($msg)) { require_once("GCM.php"); $message = array("message" => $msg); $regId = explode(",", $regId); $result = gcm_push_notification($regId, $message); $success_code = json_decode($result,true)["success"]; if($success_code > 0){ //echo $result; // echo $success_code."/".count($regId); // }else{ echo "error"; } } else { echo "error"; } ?>

The code every time will need "registration id"s to send a message:

I am wondering how can I get all registration ids every time before sending a message? And if I create a simple app which will run at emulator only, will it generate a registration id? How do I get that?

最满意答案

您可以创建一个数据库并将所有注册ID存储在服务器中。 模拟器可以生成GCM ID。 确保将模拟器目标设置为Google API。 如果您的模拟器运行的是Android 4.0及更低版本,请将Google帐户添加到模拟器中。

You could create a database and store all the registration id's in the server. And emulators can generate GCM ID. Make sure you set your emulator target to Google API. If your emulator is running Android 4.0 and below, add an Google account to your emulator.

更多推荐

message,GCM,代码,$regId,电脑培训,计算机培训,IT培训"/> <meta name="descrip

本文发布于:2023-08-04 12:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415947.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   器中   测试   PHP   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!