没有从GCM CCS收回delivery_receipt_notification

Raf*_*cia 7 go ios google-cloud-messaging

我正试图receipt从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)
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行脚本时,一切似乎都没问题,但没有回复消息:

在此输入图像描述

这是我收到通知时正在做的事情:

在此输入图像描述

我做错了什么或遗失了什么?

eva*_*ent 0

不确定你是在 Android 还是 iOS 上尝试这个,因为它在 Android 上对我有效,但在 iOS 上并不总是有效。

iOS 的送达收据不适用于notification请求中的参数。我能够让它适用于普通data消息,即带有有效负载的消息

{
  "to" : <reg id>,
  "data" : {
    "hello" : "world",
    "id" : 123
  }
}
Run Code Online (Sandbox Code Playgroud)

但如果我将notification有效负载添加到上面的有效负载中,它就不起作用了。

我假设由于notification有效负载消息需要通过 APNS 发送,因此他们无法知道消息是否已传递,因为 APNS 不返回任何结果。

对于 notification消息,因为仅当应用程序位于前台时才会收到消息,因此他们将能够验证消息是否已传递。