在App Engine中使用Go语言的模块来保持与APNs的连接开放

huangapple go评论96阅读模式
英文:

Keeping connection to APNs open on App Engine using Modules in Go

问题

我正在尝试为我编写的留言板应用实现iOS推送通知(例如新消息的通知等等),但是我真的不知道从哪里开始。

目前的很多文档似乎已经过时,关于如何在App Engine上保持与APNs的持久TLS连接以及关于已弃用后端的文章的链接。我正在使用Go运行时,但一直卡在某个地方。例如,与APNs建立套接字连接需要一个Context,而这个Context只能从HTTP请求中获取,但从架构上来看,这似乎并不合理,因为理想情况下套接字应该保持打开状态。

是否有更清晰的指南我错过了,或者现在设置一个单独的VPS或计算实例来处理它是否是一个更好的主意?

英文:

I'm trying to implement iOS push notifications for a message board app I've written (so like notification for new message etc. etc.) but have no real idea where to start.

A lot the current documentation seems to be out of date in regard to keeping persistent TLS connections open to the APNs from App Engine and links to articles about deprecated backends. I'm using the Go runtime and just keep getting stuck. For instance, the creation of the socket connection to APNs requires a Context which can only be got from a HTTP request, but architecturally this doesn't seem to make a lot of sense because ideally the socket remains open regardless.

Is there any clearer guides around that I'm missing or right now is it a better idea to set up a separate VPS or compute instance to handle it?

答案1

得分: 1

我对Go不是很熟悉,但如果你无法弄清楚如何在Go中连接到APNS,我建议创建一个单独的Java模块,负责向APNS发送推送通知,并使用任务队列将“嘿,发送这个推送通知”的消息(任务)从Go发送到这个Java模块。你可以从Go中将任务加入队列,并在Java模块中处理它们。

有一个开源的Java APNS库(https://github.com/ZsoltSafrany/java-apns-gae),你可以使用它来发送推送通知。它专门设计用于在Google App Engine上工作和使用。

关于任务入队的问题:

https://developers.google.com/appengine/docs/java/taskqueue/
https://developers.google.com/appengine/docs/go/taskqueue/

后端已被弃用,请使用模块:

https://developers.google.com/appengine/docs/java/modules/
https://developers.google.com/appengine/docs/go/modules/

英文:

I'm not that familiar with Go but if you cannot figure out how to connect to APNS in Go then I would recommend creating a separate Java Module that would be responsible for sending push notifications to APNS and a Task Queue to send 'hey-send-this-push-notification' messages (tasks) from Go to this Java Module. You could enqueue tasks from Go and process them in your Java Module.

There is an open-source, Java APNS library that you can use to send push notifications. It was specifically designed to work (and be used) on Google App Engine.

<br /><br />
Backends are deprecated; use Modules:

https://developers.google.com/appengine/docs/java/modules/
https://developers.google.com/appengine/docs/go/modules/

Regarding enqueuing tasks:

https://developers.google.com/appengine/docs/java/taskqueue/
https://developers.google.com/appengine/docs/go/taskqueue/

huangapple
  • 本文由 发表于 2014年8月21日 00:18:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/25409720.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定