Add InitAPNSClient func.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2016-03-27 13:08:31 +08:00
parent 8623a92d50
commit 5812bd30d5
2 changed files with 22 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ package gopush
import (
"github.com/google/go-gcm"
apns "github.com/sideshow/apns2"
"github.com/sideshow/apns2/certificate"
"github.com/sideshow/apns2/payload"
"log"
)
@@ -58,6 +59,26 @@ type RequestPushNotification struct {
IDs []uint64 `json:"seq_id,omitempty"`
}
func InitAPNSClient() {
if PushConf.Ios.Enabled {
var err error
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemKeyPath, "")
if err != nil {
log.Println("Cert Error:", err)
return
}
if PushConf.Ios.Production {
ApnsClient = apns.NewClient(CertificatePemIos).Production()
} else {
ApnsClient = apns.NewClient(CertificatePemIos).Development()
}
}
}
func pushNotification(notification RequestPushNotification) bool {
var (
success bool