From ca7d3b6e7bc2e52cf40180a462492313f298e760 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Thu, 23 Feb 2017 08:53:43 -0500 Subject: Adding device Id for version 2 of native apps (#5505) * Adding device Id for version 2 * Changing ids --- model/push_notification.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'model/push_notification.go') diff --git a/model/push_notification.go b/model/push_notification.go index 3c010fb75..c426e01e5 100644 --- a/model/push_notification.go +++ b/model/push_notification.go @@ -10,8 +10,10 @@ import ( ) const ( - PUSH_NOTIFY_APPLE = "apple" - PUSH_NOTIFY_ANDROID = "android" + PUSH_NOTIFY_APPLE = "apple" + PUSH_NOTIFY_ANDROID = "android" + PUSH_NOTIFY_APPLE_REACT_NATIVE = "apple_rn" + PUSH_NOTIFY_ANDROID_REACT_NATIVE = "android_rn" PUSH_TYPE_MESSAGE = "message" PUSH_TYPE_CLEAR = "clear" @@ -46,12 +48,11 @@ func (me *PushNotification) ToJson() string { } func (me *PushNotification) SetDeviceIdAndPlatform(deviceId string) { - if strings.HasPrefix(deviceId, PUSH_NOTIFY_APPLE+":") { - me.Platform = PUSH_NOTIFY_APPLE - me.DeviceId = strings.TrimPrefix(deviceId, PUSH_NOTIFY_APPLE+":") - } else if strings.HasPrefix(deviceId, PUSH_NOTIFY_ANDROID+":") { - me.Platform = PUSH_NOTIFY_ANDROID - me.DeviceId = strings.TrimPrefix(deviceId, PUSH_NOTIFY_ANDROID+":") + + parts := strings.Split(deviceId, ":") + if len(parts) == 2 { + me.Platform = parts[0] + me.DeviceId = parts[1] } } -- cgit v1.2.3-1-g7c22