parent
b35a831a41
commit
6bad4797b4
|
@ -98,7 +98,12 @@ func InitAPNSClient() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ext == ".p8" && PushConf.Ios.KeyID != "" && PushConf.Ios.TeamID != "" {
|
if ext == ".p8" {
|
||||||
|
if PushConf.Ios.KeyID == "" || PushConf.Ios.TeamID == "" {
|
||||||
|
msg := "You should provide ios.KeyID and ios.TeamID for P8 token"
|
||||||
|
LogError.Error(msg)
|
||||||
|
return errors.New(msg)
|
||||||
|
}
|
||||||
token := &token.Token{
|
token := &token.Token{
|
||||||
AuthKey: authKey,
|
AuthKey: authKey,
|
||||||
// KeyID from developer account (Certificates, Identifiers & Profiles -> Keys)
|
// KeyID from developer account (Certificates, Identifiers & Profiles -> Keys)
|
||||||
|
|
|
@ -609,6 +609,22 @@ func TestAPNSClientInvaildToken(t *testing.T) {
|
||||||
PushConf.Ios.KeyType = "p8"
|
PushConf.Ios.KeyType = "p8"
|
||||||
err = InitAPNSClient()
|
err = InitAPNSClient()
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
//empty key-id or team-id
|
||||||
|
PushConf.Ios.Enabled = true
|
||||||
|
PushConf.Ios.KeyPath = "../certificate/authkey-valid.p8"
|
||||||
|
err = InitAPNSClient()
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
PushConf.Ios.KeyID = "key-id"
|
||||||
|
PushConf.Ios.TeamID = ""
|
||||||
|
err = InitAPNSClient()
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
PushConf.Ios.KeyID = ""
|
||||||
|
PushConf.Ios.TeamID = "team-id"
|
||||||
|
err = InitAPNSClient()
|
||||||
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPNSClientVaildToken(t *testing.T) {
|
func TestAPNSClientVaildToken(t *testing.T) {
|
||||||
|
@ -616,6 +632,8 @@ func TestAPNSClientVaildToken(t *testing.T) {
|
||||||
|
|
||||||
PushConf.Ios.Enabled = true
|
PushConf.Ios.Enabled = true
|
||||||
PushConf.Ios.KeyPath = "../certificate/authkey-valid.p8"
|
PushConf.Ios.KeyPath = "../certificate/authkey-valid.p8"
|
||||||
|
PushConf.Ios.KeyID = "key-id"
|
||||||
|
PushConf.Ios.TeamID = "team-id"
|
||||||
err := InitAPNSClient()
|
err := InitAPNSClient()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host)
|
assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host)
|
||||||
|
|
10
main.go
10
main.go
|
@ -60,6 +60,8 @@ func main() {
|
||||||
flag.StringVar(&opts.Core.PID.Path, "pid", "", "PID file path.")
|
flag.StringVar(&opts.Core.PID.Path, "pid", "", "PID file path.")
|
||||||
flag.StringVar(&opts.Ios.KeyPath, "i", "", "iOS certificate key file path")
|
flag.StringVar(&opts.Ios.KeyPath, "i", "", "iOS certificate key file path")
|
||||||
flag.StringVar(&opts.Ios.KeyPath, "key", "", "iOS certificate key file path")
|
flag.StringVar(&opts.Ios.KeyPath, "key", "", "iOS certificate key file path")
|
||||||
|
flag.StringVar(&opts.Ios.KeyID, "key-id", "", "iOS Key ID for P8 token")
|
||||||
|
flag.StringVar(&opts.Ios.TeamID, "team-id", "", "iOS Team ID for P8 token")
|
||||||
flag.StringVar(&opts.Ios.Password, "P", "", "iOS certificate password for gorush")
|
flag.StringVar(&opts.Ios.Password, "P", "", "iOS certificate password for gorush")
|
||||||
flag.StringVar(&opts.Ios.Password, "password", "", "iOS certificate password for gorush")
|
flag.StringVar(&opts.Ios.Password, "password", "", "iOS certificate password for gorush")
|
||||||
flag.StringVar(&opts.Android.APIKey, "k", "", "Android api key configuration for gorush")
|
flag.StringVar(&opts.Android.APIKey, "k", "", "Android api key configuration for gorush")
|
||||||
|
@ -111,6 +113,14 @@ func main() {
|
||||||
gorush.PushConf.Ios.KeyPath = opts.Ios.KeyPath
|
gorush.PushConf.Ios.KeyPath = opts.Ios.KeyPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.Ios.KeyID != "" {
|
||||||
|
gorush.PushConf.Ios.KeyID = opts.Ios.KeyID
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.Ios.TeamID != "" {
|
||||||
|
gorush.PushConf.Ios.TeamID = opts.Ios.TeamID
|
||||||
|
}
|
||||||
|
|
||||||
if opts.Ios.Password != "" {
|
if opts.Ios.Password != "" {
|
||||||
gorush.PushConf.Ios.Password = opts.Ios.Password
|
gorush.PushConf.Ios.Password = opts.Ios.Password
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue