mentionapp / apns.go

Client library for the Apple Push Notification Service (APNS), focusing on reliability
Other
5 stars 1 forks source link

Topic vs Payload #3

Open joelchen opened 9 years ago

joelchen commented 9 years ago

I am following the example usage, and encountered the following panic during runtime:

PANIC: interface conversion: apns.Topic is apns.Payload, not *apns.Payload

Removing the (*apns.Payload) gives me the following build error:

payload.Set undefined (type apns.Topic has no field or method Set)

Looking through the source code, I found that Payload was recently changed to Topic, however the functions are still under Payload.

arnaud-lb commented 9 years ago

Thanks !

The recent change allows to use alternate payload formats: Notification accepts anything implementing the Topic interface as a payload. Unfortunately this changes the interface a bit.

I've fixed the example. The best way to use the library is now to instantiate a Payload object, and then set it on the Notification using SetPayload:

payload := &apns.Payload{}
payload.SetAlertString(msg.Text)
notif.SetPayload(payload)