timehop / apns

A Go package to interface with the Apple Push Notification Service
https://godoc.org/github.com/timehop/apns
MIT License
185 stars 47 forks source link

fatal error: all goroutines are asleep - deadlock! #69

Open sorawa opened 8 years ago

sorawa commented 8 years ago
package main

import (
  "fmt"
  "github.com/timehop/apns"
)

func main() {
     c, _ := apns.NewClient("gateway.sandbox.push.apple.com:2195", "dev_ck.pem", "dev_pk.pem")

    p := apns.NewPayload()
    p.APS.Alert.Body = "I am a push notification!"
    p.APS.Badge.Set(5)
    p.APS.Sound = "turn_down_for_what.aiff"

    m := apns.NewNotification()
    m.Payload = p
    m.DeviceToken = "A_DEVICE_TOKEN"
    m.Priority = apns.PriorityImmediate

    resp := c.Send(m)
    fmt.Printf("%v\n",resp)
}

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan send (nil chan)]: main.main() D:/go/bin/project/src/applePush/applyPush.go:21 +0x1b2 exit status 2 ``

nathany commented 8 years ago

The first issue I see is that you should use NewClientWithFiles instead of NewClient. It's always good to check errors that functions return.