谷歌/苹果推送通知服务(APNS / GCM) [英] Google/Apple Push Notification Service (APNS/GCM)

查看:819
本文介绍了谷歌/苹果推送通知服务(APNS / GCM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建应用程序的Andr​​oid和iOS和我watn在这两个应用程序中使用推送通知。我将不得不将发送通知的服务器应用程序。

I'm trying to create application for Android and iOS and I watn to use push notification on both the application. I'm going to have a server app that will be sending the notification.

我试图找出是我们如何能够存储用户的设备,所以我会知道哪些服务需要使用APNS或GCM。

What I'm trying to figure out is how can we store the device of the user so I'll know which service need to be used APNS or GCM.

一个方向的是让电话类型由该应用被设置并存储在服务器端此信息,但如果用户从iOS的至Android改变他的电话会发生什么情况,需要涉及该用户的数据存储并收集信息,为每一位用户,不涉及方案时,用户拥有Android平板电脑和iOS手机。

One of the directions is to get the phone type to be set by the app and store this information on the server side, but what happens if the user changes his phone from iOS to Android, need to involve data storage of the user and collect information for every user, not covers scenario when user has Android tablet and iOS phone.

请它更通用并调度通知到两个服务APNS和GCM的同时,其中之一将返回错误?

Make it more generic and dispatch the notification to both services APNS and GCM at the same time, one of them will return error?

很想听听什么是这种情况下的最佳做法是什么?

Would love to hear what is the best practice for such scenarios?

推荐答案

这是贯彻落实APNS和GCM非常简单。
请按照步骤,你会觉得它那么简单了。

This is very simple to implement APNS and GCM. Please follow the steps and you will feel its so simple.


  • 当APNS(iOS设备)和GCM(Android设备)注册了苹果和谷歌服务器上的推送通知它产生每个设备唯一令牌。

  • 之后,您需要保存该设备的原因,您的设备ID或用户ID(您的服务器设备上的唯一ID)和设备的操作系统。

像和iOS设备发送服务器(后端),您可以使用此JSON此信息格式化
{令牌:abcdedfgehik2bd3d3ff3sffssdff,OS:iOS版,用户ID:34}

Like and iOS device is sending this information on your server (backend) you can use this JSON format- {"token":"abcdedfgehik2bd3d3ff3sffssdff","os":"iOS","userid":34}

有关Android设备将是 -
{令牌:erydnfbdbdjskd76ndjs7nnshdjs,OS:机器人,用户ID:35}

For android device it will be - {"token":"erydnfbdbdjskd76ndjs7nnshdjs","os":"Android","userid":35}

通过它您可以识别设备的操作系统,以及将被用于发送推送通知用户信息和唯一令牌。

By this you can identify the OS of device, as well as user information and unique token which will be used for sending push notification.

祝您好运!

这篇关于谷歌/苹果推送通知服务(APNS / GCM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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