iOS 对 Google Cloud Messaging 的支持

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15578280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 22:49:58  来源:igfitidea点击:

iOS support for Google Cloud Messaging

iospush-notificationgoogle-cloud-messaging

提问by Alejandro Fraenkel

I saw in google's developer console that GCM allows to generate a API key for iOS. I searched in the web for any kind of documentation about how to implement Push Notifications throught GCM in an iOS App, but i didn't find answers.

我在 google 的开发者控制台中看到 GCM 允许为 iOS 生成 API 密钥。我在网上搜索了有关如何在 iOS 应用程序中通过 GCM 实现推送通知的任何类型的文档,但我没有找到答案。

Is It really possible to implement Push Notifications jet using GCM in iOS apps? documentation, examples or something to learn how to do this?

是否真的可以在 iOS 应用程序中使用 GCM 实现推送通知喷射?文档,示例或学习如何做到这一点的东西?

Thanks!

谢谢!

回答by MadNik

YES

是的

I tried it and it works great. Follow this https://developers.google.com/cloud-messaging/ios/start

我试过了,效果很好。按照这个https://developers.google.com/cloud-messaging/ios/start

This is how it works.

这就是它的工作原理。

You create app entry at google console. Upload development and production certificated in creation wizard.(You have to upload both) and follow the steps in docs.

您在谷歌控制台创建应用程序条目。上传创建向导中认证的开发和生产。(您必须同时上传两者)并按照文档中的步骤操作。

Logic works as follows

逻辑工作如下

  1. We request device token from apns as usual.
  2. Then we send that token to gcm service with provided api.
  3. Then gcm sends back a another token.
  4. We send that token to app server.
  5. App server can send notifications using that token.
  1. 我们像往常一样从 apns 请求设备令牌。
  2. 然后我们使用提供的 api 将该令牌发送到 gcm 服务。
  3. 然后 gcm 发回另一个令牌。
  4. 我们将该令牌发送到应用服务器。
  5. 应用服务器可以使用该令牌发送通知。

Cool Features.

很酷的功能。

GCM for iOS has some cool features as

iOS 版 GCM 有一些很酷的功能,如

  • Subscribe to notification based on a particular topic. Ignore others.

  • Send Notification to other devices within the app.

  • 订阅基于特定主题的通知。无视其他人。

  • 向应用内的其他设备发送通知。

If you want to try google sample app. UPDATE: it's Google with a capital G now. Just

如果你想尝试谷歌示例应用程序。更新:现在是大写 G 的 Google。只是

pod try Google

There you will get an example in ObjC , swift and even mac app that can send notification.

在那里,您将获得 ObjC、swift 甚至 mac 应用程序中可以发送通知的示例。

Update.

更新。

Google is moving to Firebase cloud messageingfrom GCM.

Google 正在从 GCM转向Firebase 云消息传递

回答by Scott Leslie

Google has now introduced Google Cloud Platform for iOS. See their blog entryfor more information. Google Cloud Messaging is supported now for both Android and iOS.

谷歌现已推出适用于 iOS 的谷歌云平台。有关更多信息,请参阅他们的博客条目。现在 Android 和 iOS 都支持 Google Cloud Messaging。

回答by Sergio Feo

Google has updated their online documentation. You still need a valid APNS certificate. After, your app can register with GCM using the iOS GCM API. Your notifications server should work without modification.

谷歌更新了他们的在线文档。您仍然需要有效的 APNS 证书。之后,您的应用程序可以使用iOS GCM APIGCM注册。您的通知服务器应该无需修改即可工作。

回答by Javi Vazquez

the answer is yes, you can use Google Cloud Messaging API to communicate with iOS devices, but its quite a complex process. You can read the official documentation on https://cloud.google.com/resources/articles/ios-push-notifications

答案是肯定的,您可以使用 Google Cloud Messaging API 与 iOS 设备进行通信,但这是一个相当复杂的过程。您可以在https://cloud.google.com/resources/articles/ios-push-notifications上阅读官方文档

Regards

问候

回答by Sean Abraham

As of Google I/O 2015, Google officially added iOS support for GCM. You can find more information here: https://developers.google.com/cloud-messaging/ios/start

从 Google I/O 2015 开始,Google 正式添加了对 GCM 的 iOS 支持。您可以在此处找到更多信息:https: //developers.google.com/cloud-messaging/ios/start

回答by Patrick Tescher

While some Google APIs work with iOS GCM is for Android only. The only way to send push notifications to iOS devices is through the Apple push notification system. Google would have to support this.

虽然一些 Google API 可与 iOS 配合使用,但 GCM 仅适用于 Android。向 iOS 设备发送推送通知的唯一方法是通过 Apple 推送通知系统。谷歌将不得不支持这一点。

You can always us something like Urban Airship if you want to push to multiple platforms.

如果您想推送到多个平台,您可以随时使用 Urban Airship 之类的东西。

回答by Maurice

The response is nofor Google Cloud Messaging. However it's possible to send push notification to iOS devices using Google Cloud Platformwith Google App Engineand Google Cloud Endpoints. (See this documentation)
But you will need inevitably to communicate with the Apple Push Notication Service. The task to do it is for sure more complex than using directly the Apple service.

Google Cloud Messaging的响应是否定的。但是,可以使用带有Google App EngineGoogle Cloud Endpoints 的Google Cloud Platform向 iOS 设备发送推送通知。(请参阅此文档) 但您将不可避免地需要与 Apple 推送通知服务进行通信。这样做的任务肯定比直接使用 Apple 服务更复杂。

回答by Sebastien Marion

Wow, this is really bad. Actually you need to modify the client on iOS for this to work! In my company this is just not an option unfortunately, so back to Amazon SNS.

哇,这真的很糟糕。实际上,您需要修改 iOS 上的客户端才能使其正常工作!不幸的是,在我的公司,这不是一个选择,所以回到 Amazon SNS。

The idea here is that with Google's implementation you only need to communicate with the GCM, but in order to send a message to iOS, then your device will have had to sync with GCM first to pass tokens etc, hence the need for the iOS client library.

这里的想法是,使用 Google 的实现,您只需要与 GCM 通信,但是为了向 iOS 发送消息,您的设备必须首先与 GCM 同步以传递令牌等,因此需要 iOS 客户端图书馆。

As a user of Google App Engine, I was really excited by this, but this is a real let down.

作为 Google App Engine 的用户,我对此感到非常兴奋,但这确实令人失望。