未从GCM CCS收到交付回执通知。

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

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:

未从GCM CCS收到交付回执通知。

And this is what I'm doing when I get the notification:

未从GCM CCS收到交付回执通知。

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

{
  &quot;to&quot; : &lt;reg id&gt;,
  &quot;data&quot; : {
    &quot;hello&quot; : &quot;world&quot;,
    &quot;id&quot; : 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.

huangapple
  • 本文由 发表于 2015年7月4日 03:11:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/31212974.html
匿名

发表评论

匿名网友

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

确定