Skip to content
Snippets Groups Projects
Commit bc993c4d authored by Jonah Husson's avatar Jonah Husson
Browse files

Easy toggle for apns gateway

parent 4c7d4661
No related branches found
No related tags found
1 merge request!5Release
......@@ -41,5 +41,6 @@ apnsKeyPath: ""
apnsKeyID: ""
apnsIssuer: ""
apnsBundleID: ""
apnsDev: true
# === END YAML
```
......@@ -81,6 +81,7 @@ var rootCmd = &cobra.Command{
KeyID: viper.GetString("apnsKeyID"),
Issuer: viper.GetString("apnsIssuer"),
BundleID: viper.GetString("apnsBundleID"),
Dev: viper.GetBool("apnsDev"),
},
}
......
......@@ -52,6 +52,7 @@ type APNSParams struct {
KeyID string
Issuer string
BundleID string
Dev bool
}
// Local impl for notifications; holds comms, storage object, creds and main functions
......@@ -116,12 +117,19 @@ func StartNotifications(params Params, noTLS, noFirebase bool) (*Impl, error) {
if err != nil {
return nil, errors.WithMessage(err, "Failed to read APNS key")
}
var endpoint apns.ClientOption
if params.APNS.Dev {
jww.INFO.Println("")
endpoint = apns.WithEndpoint(apns.DevelopmentGateway)
} else {
endpoint = apns.WithEndpoint(apns.ProductionGateway)
}
apnsClient, err := apns.NewClient(
apns.WithJWT(apnsKey, params.APNS.KeyID, params.APNS.Issuer),
apns.WithBundleID(params.APNS.BundleID),
apns.WithMaxIdleConnections(100),
apns.WithTimeout(5*time.Second))
apns.WithTimeout(5*time.Second),
endpoint)
if err != nil {
return nil, errors.WithMessage(err, "Failed to setup apns client")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment