英文:
Not receiving back a delivery_receipt_notification from GCM CCS
问题
我正在尝试从CCS获取一张收据,但是我无法成功。
以下是我的操作步骤:
我有一个go
脚本:
package main
import (
"fmt"
"github.com/brunohenrique/go-gcm/ccs"
)
var (
user = struct {
gcmToken string
}{"mg0xe56LfjE:APA91bFHtHVQt85iNgyzTeDowovIGPAD_NbBjURppy1LgV9_oaM2R_9zn1fDXNuEeOoALTj7F8e8JmNPI3Md-CbbgTxdvxVrONFVfGz2dOujsaGkZjEhJcBH8sWvRNYZNIp2j2QliAEX"}
)
func main() {
con := connect()
// Sends a message
con.Send(&ccs.OutMsg{
To: user.gcmToken,
ID: "m-1366082849205",
Notification: map[string]interface{}{
"title": "Hey!",
"body": "There",
"sound": "default",
},
TimeToLive: 600,
DeliveryReceiptRequested: true,
DelayWhileIdle: true,
})
// Listen to messages
for {
m, err := con.Receive()
if err != nil {
fmt.Printf(">>> Err: %+v \n", err)
}
go func(m *ccs.InMsg) {
fmt.Printf(">>> InMsg: %+v \n", m)
}(m)
}
}
当我运行脚本时,一切似乎都正常,但没有收到回执消息。
这是我收到通知时的操作:
Am I doing something wrong or missing something?
英文:
I'm trying to get a receipt
from CCS, but I'm just not able to.
Here is what I'm doing:
I have a go
script:
package main
import (
"fmt"
"github.com/brunohenrique/go-gcm/ccs"
)
var (
user = struct {
gcmToken string
}{"mg0xe56LfjE:APA91bFHtHVQt85iNgyzTeDowovIGPAD_NbBjURppy1LgV9_oaM2R_9zn1fDXNuEeOoALTj7F8e8JmNPI3Md-CbbgTxdvxVrONFVfGz2dOujsaGkZjEhJcBH8sWvRNYZNIp2j2QliAEX"}
)
func main() {
con := connect()
// Sends a message
con.Send(&ccs.OutMsg{
To: user.gcmToken,
ID: "m-1366082849205",
Notification: map[string]interface{}{
"title": "Hey!",
"body": "There",
"sound": "default",
},
TimeToLive: 600,
DeliveryReceiptRequested: true,
DelayWhileIdle: true,
})
// Listen to messages
for {
m, err := con.Receive()
if err != nil {
fmt.Printf(">>> Err: %+v \n", err)
}
go func(m *ccs.InMsg) {
fmt.Printf(">>> InMsg: %+v \n", m)
}(m)
}
}
Everything seems alright when I run the script, but no receipt message back:
And this is what I'm doing when I get the notification:
Am I doing something wrong or missing something?
答案1
得分: 1
很抱歉,目前在iOS上无法显示推送通知的送达回执。感谢您尝试在iOS上使用GCM。
英文:
Thanks for trying out GCM on iOS.
Unfortunately, delivery receipts are not available for display notifications on iOS at the moment.
答案2
得分: 0
不确定您是在Android还是iOS上尝试此操作,因为在Android上可以正常工作,但在iOS上不一定有效。
iOS上的传递回执在请求中的notification
参数中不起作用。我能够使其对一个普通的data
消息起作用,即使用以下有效载荷:
{
"to" : <reg id>,
"data" : {
"hello" : "world",
"id" : 123
}
}
但是,如果我将上述有效载荷添加到notification
有效载荷中,它就不起作用了。
我认为,由于notification
有效载荷消息需要通过APNS发送,他们无法知道消息是否已传递,因为APNS不返回任何结果。
对于一个不是 notification
消息,因为它只在应用程序在前台时接收到,他们可以验证消息是否已传递。
英文:
Not sure if you're trying this on Android or iOS, since it works for me on Android but it doesn't always work on iOS.
Delivery receipts for iOS do not work with the notification
parameter in the request. I was able to get it to work for a plain data
message i.e. with payload
{
"to" : <reg id>,
"data" : {
"hello" : "world",
"id" : 123
}
}
But if I added the notification
payload to the above one it didn't work.
I would assume that since a notification
payload message needs to be sent via APNS there is no way for them to know whether the message was delivered or not since APNS does not return any result.
For a <b>no</b> notification
message since it's received only when the app is in the foreground they would be able to verify if the message was delivered or not.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论