Example #1
0
    /// <summary>
    /// Obtains the device token if available.
    /// </summary>
    /// <returns>
    /// If the token was correctly obtained.
    /// </returns>
    public bool ObtainIOSDeviceToken()
    {
        if (config.PushNotificationEnabled)
        {
            byte[] token = NotificationServices.deviceToken;

            if (token != null)
            {
                // Send token as user update and to Babble if QA user
                string hexToken       = SwrveHelper.FilterNonAlphanumeric(System.BitConverter.ToString(token));
                bool   sendDeviceInfo = (iOSdeviceToken != hexToken);
                if (sendDeviceInfo)
                {
                    iOSdeviceToken = hexToken;
                    // Save device token for future launches
                    storage.Save(iOSdeviceTokenSave, iOSdeviceToken);
                    SendDeviceInfo();

                    if (qaUser != null)
                    {
                        qaUser.UpdateDeviceInfo();
                    }
                }

                return(true);
            }
        }

        return(false);
    }