private string getNativeLanguage()
    {
        string language = null;

        if (SwrveHelper.IsOnDevice())
        {
            try {
                using (AndroidJavaClass localeJavaClass = new AndroidJavaClass("java.util.Locale")) {
                    AndroidJavaObject defaultLocale = localeJavaClass.CallStatic <AndroidJavaObject>("getDefault");
                    language = defaultLocale.Call <string>("getLanguage");
                    string country = defaultLocale.Call <string>("getCountry");
                    if (!string.IsNullOrEmpty(country))
                    {
                        language += "-" + country;
                    }
                    string variant = defaultLocale.Call <string>("getVariant");
                    if (!string.IsNullOrEmpty(variant))
                    {
                        language += "-" + variant;
                    }
                }
            } catch (Exception exp) {
                SwrveLog.LogWarning("Couldn't get the device language, make sure you are running on an Android device: " + exp.ToString());
            }
        }
        return(language);
    }
Exemplo n.º 2
0
 public virtual void SaveSecure(string tag, string data, string userId = null)
 {
     if (!string.IsNullOrEmpty(data))
     {
         bool flag = false;
         try
         {
             string fileName = GetFileName(tag, userId);
             SwrveLog.Log("Saving: " + fileName, "storage");
             CrossPlatformFile.SaveText(fileName, data);
             string path  = fileName + "_SGT";
             string data2 = SwrveHelper.CreateHMACMD5(data, uniqueKey);
             CrossPlatformFile.SaveText(path, data2);
             flag = true;
         }
         catch (Exception ex)
         {
             SwrveLog.LogError(ex.ToString(), "storage");
         }
         if (!flag)
         {
             SwrveLog.LogWarning(tag + " not saved!", "storage");
         }
     }
 }
        public virtual void SaveSecure(string tag, string data, string userId = null)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            bool saved = false;

            try {
                string saveFileName = GetFileName(tag, userId);
                SwrveLog.Log("Saving: " + saveFileName, "storage");
                CrossPlatformFile.SaveText(saveFileName, data);
                string signatureFileName = saveFileName + SIGNATURE_SUFFIX;
                string signature         = SwrveHelper.CreateHMACMD5(data, uniqueKey);

                CrossPlatformFile.SaveText(signatureFileName, signature);

                saved = true;
            } catch (Exception e) {
                SwrveLog.LogError(e.ToString(), "storage");
            }

            if (!saved)
            {
                SwrveLog.LogWarning(tag + " not saved!", "storage");
            }
        }
Exemplo n.º 4
0
 public void LocationUserUpdate(Dictionary <string, string> map)
 {
     try {
         _swrveiOSLocationUserUpdate(Json.Serialize(map));
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't update location details from iOS: " + exp.ToString());
     }
 }
Exemplo n.º 5
0
 private void showNativeConversation(string conversation)
 {
     try {
         _swrveiOSShowConversation(conversation);
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't get show conversation correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
     }
 }
 private void showNativeConversation(string conversation)
 {
     try {
         AndroidGetBridge().Call(ShowConversationName, conversation);
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't show conversation from Android: " + exp.ToString());
     }
 }
 private void setNativeConversationVersion()
 {
     try {
         SetConversationVersion(AndroidGetBridge().Call <int> (GetConversationVersionName));
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't get conversations version from Android: " + exp.ToString());
     }
 }
Exemplo n.º 8
0
 private void initNative()
 {
     try {
         _swrveiOSInitNative(GetNativeDetails());
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't get init the native side correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
     }
 }
Exemplo n.º 9
0
 private void startNativeLocation()
 {
     try {
         _swrveiOSStartLocation();
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't start Location on iOS correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
     }
 }
 private void AndroidInitNative()
 {
     try {
         AndroidGetBridge();
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't init common from Android: " + exp.ToString());
     }
 }
Exemplo n.º 11
0
 public string GetPlotNotifications()
 {
     try {
         return(_swrveiOSGetPlotNotifications());
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't get plot notifications from iOS: " + exp.ToString());
     }
     return("[]");
 }
Exemplo n.º 12
0
 private string getNativeLanguage()
 {
     try {
         return(_swrveiOSGetLanguage());
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't get the device language, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
     }
     return(null);
 }
Exemplo n.º 13
0
 private void setNativeAppVersion()
 {
     try {
         config.AppVersion = _swrveiOSGetAppVersion();
         SwrveLog.Log("got iOS version name " + config.AppVersion);
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't get the device app version, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
     }
 }
 private void SetDefaultNotificationChannel()
 {
     try {
         AndroidChannel defaultChannel = (config.DefaultAndroidChannel != null) ? config.DefaultAndroidChannel : FallbackDefaultChannel();
         AndroidGetBridge().Call(SetDefaultNotificationChannelName, defaultChannel.Id, defaultChannel.Name, defaultChannel.Importance.ToString());
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't set default notification channel in Android: " + exp.ToString());
     }
 }
Exemplo n.º 15
0
    private void setNativeConversationVersion()
    {
#if !UNITY_EDITOR
        try {
            SetConversationVersion(_swrveiOSConversationVersion());
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't start Conversations on iOS correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
        }
#endif
    }
Exemplo n.º 16
0
    public void updateQAUser(Dictionary <string, object> map)
    {
#if !UNITY_EDITOR
        try {
            _swrveiOSUpdateQaUser(Json.Serialize(map));
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't update QA user from iOS: " + exp.ToString());
        }
#endif
    }
Exemplo n.º 17
0
    private string getNativeRandomUUID()
    {
        string uuid = null;

        try {
            uuid = _swrveiOSUUID();
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't get random UUID: " + exp.ToString());
        }
        return(uuid);
    }
 public void LocationUserUpdate(Dictionary <string, string> map)
 {
     if (SwrveHelper.IsOnDevice())
     {
         try {
             AndroidGetBridge().CallStatic(SwrveLocationUserUpdateName, Json.Serialize(map));
         } catch (Exception exp) {
             SwrveLog.LogWarning("Couldn't update location details from Android: " + exp.ToString());
         }
     }
 }
Exemplo n.º 19
0
    public static bool IsSupportediOSVersion()
    {
#if !UNITY_EDITOR
        try {
            return(_swrveiOSIsSupportedOSVersion());
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't get init the native side correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
        }
#endif
        return(true);
    }
Exemplo n.º 20
0
    private void initNative()
    {
#if !UNITY_EDITOR
        try {
            _swrveiOSInitNative(GetNativeDetails());
            RefreshPushPermissions();
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't get init the native side correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
        }
#endif
    }
Exemplo n.º 21
0
    public static string GetiOSPlatformOS()
    {
#if !UNITY_EDITOR
        try {
            return(_swrveiOSGetPlatformOS());
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't get init the native side correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
        }
#endif
        return("ios"); // if there is no native response, we default to "ios"
    }
Exemplo n.º 22
0
    public string GetInfluencedDataJson()
    {
#if !UNITY_EDITOR
        try {
            return(_swrveInfluencedDataJson());
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't get InfluencedDataJson from the native side correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
        }
#endif
        return(null);
    }
Exemplo n.º 23
0
    private static bool IsConversationDisplaying()
    {
#if !UNITY_EDITOR
        try {
            return(_swrveiOSIsConversationDisplaying());
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't init the native side correctly, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
        }
#endif
        return(false); // Defaulting to false so messages can still appear in the editor
    }
 private void UpdateNativeUserId()
 {
     if (SwrveHelper.IsOnDevice())
     {
         try {
             AndroidGetBridge().Call(SetUserIdName, this.profileManager.userId);
         } catch (Exception exp) {
             SwrveLog.LogWarning("Couldn't set userId from Android: " + exp.ToString());
         }
     }
 }
    private string AndroidGetTimezone()
    {
        try {
            AndroidJavaObject cal = new AndroidJavaObject("java.util.GregorianCalendar");
            return(cal.Call <AndroidJavaObject>("getTimeZone").Call <string>("getID"));
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't get the device timezone, make sure you are running on an Android device: " + exp.ToString());
        }

        return(null);
    }
Exemplo n.º 26
0
    protected void RegisterForPushNotificationsIOS(bool isProvisional)
    {
#if !UNITY_EDITOR
        try {
            _swrveiOSRegisterForPushNotifications(Json.Serialize(config.NotificationCategories.Select(a => a.toDict()).ToList()), isProvisional);
            _saveConfigForPushDelivery();
        } catch (Exception exp) {
            SwrveLog.LogWarning("Couldn't invoke native code to register for push notifications, make sure you have the iOS plugin inside your project and you are running on a iOS device: " + exp.ToString());
            NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound);
        }
#endif
    }
 public string GetPlotNotifications()
 {
     if (SwrveHelper.IsOnDevice())
     {
         try {
             return(AndroidGetBridge().CallStatic <string>(SwrveGetPlotNotificationsName));
         } catch (Exception exp) {
             SwrveLog.LogWarning("Couldn't get plot notifications from Android: " + exp.ToString());
         }
     }
     return("[]");
 }
 private void startNativeLocation()
 {
     if (SwrveHelper.IsOnDevice())
     {
         try {
             AndroidGetBridge().CallStatic(SwrveStartLocationName);
             startedPlot = true;
         } catch (Exception exp) {
             SwrveLog.LogWarning("Couldn't start Swrve location from Android: " + exp.ToString());
         }
     }
 }
Exemplo n.º 29
0
        private string AndroidGetTelephonyManagerAttribute(string method)
        {
            if (androidTelephonyManager != null)
            {
                try {
                    return(androidTelephonyManager.Call <string>(method));
                } catch (Exception exp) {
                    SwrveLog.LogWarning("Problem accessing the TelephonyManager - " + method + ": " + exp.ToString());
                }
            }

            return(null);
        }
Exemplo n.º 30
0
 public DeviceCarrierInfo()
 {
     try {
         using (AndroidJavaClass contextClass = new AndroidJavaClass("android.content.Context"))
             using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                 using (AndroidJavaObject context = unityPlayerClass.GetStatic <AndroidJavaObject>("currentActivity")) {
                     string telephonyService = contextClass.GetStatic <string>("TELEPHONY_SERVICE");
                     androidTelephonyManager = context.Call <AndroidJavaObject>("getSystemService", telephonyService);
                 }
     } catch (Exception exp) {
         SwrveLog.LogWarning("Couldn't get access to TelephonyManager: " + exp.ToString());
     }
 }