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
", err)
}
go func(m *ccs.InMsg) {
fmt.Printf(">>> InMsg: %+v
", 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?
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 no 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.
Thanks for trying out GCM on iOS. Unfortunately, delivery receipts are not available for display notifications on iOS at the moment.