Als ich versuchte, Push-Benachrichtigung in Golang App Engine mit Onesignal-Umgebung zu implementieren.Aber iam bekommen Fehler "http.DefaultTransport und http.DefaultClient nicht verfügbar sind in App Engine" .Dies ist mein Code,https://onesignal.com/api/v1//notifications: http.DefaultTransport und http.DefaultClient sind nicht verfügbar in App Engine
func (c *PushNotificationController) CreateNotification() {
client := onesignal.NewClient(nil)
client.AppKey = "MyAppKey"
client.UserKey = "MyUserKey"
notifID := CreateNotifications(client)
log.Println(notifID)
}
func CreateNotifications(client *onesignal.Client) string {
playerID := "SamplePlayerId" // valid
notificationReq := &onesignal.NotificationRequest{
AppID: "MyAppKey",
Contents: map[string]string{"en": "English message"},
IsIOS: true,
IncludePlayerIDs: []string{playerID},
}
if createRes, res, err := client.Notifications.Create(notificationReq){
if err != nil {
log.Fatal(err)
}
return createRes.ID
}
...
}
Gibt es eine Möglichkeit, das Paket App-Engine kompatibel zu machen? Das Paket dient zum Senden von Push-Benachrichtigungen mit dem Signal –
@farsanapb urlfetch sollte übergeben werden Context via: 'c: = appengine.NewContext (r)' Dieses 'r' ist das Anfrageobjekt. Das Hinzufügen von context.Context für NewXXX scheint mir eine gute Idee zu sein. – mattn