Lorsque j'ai essayé d'implémenter la notification push dans golang App Engine à l'aide de l'envi de unsignal.But, j'obtiens une erreur "http.DefaultTransport et http.DefaultClient ne sont pas disponibles dans l'App Engine" .C'est mon code,https://onesignal.com/api/v1//notifications: http.DefaultTransport et http.DefaultClient ne sont pas disponibles dans 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
}
...
}
Est-il possible de rendre le moteur de l'application de package compatible? Le paquet est pour l'envoi de notifications push en utilisant un signal –
@farsanapb urlfetch doit être passé Contexte via: 'c: = appengine.NewContext (r)' Ce 'r' est un objet de requête. Donc l'ajout de context.Contexte pour NewXXX semble être une bonne idée pour moi. – mattn