Ejemplo n.º 1
0
        public static void FailureCallback(IntPtr actionPtr, string serializedError)
        {
            GetSocialDebugLogger.D("FailureCallback: " + serializedError + ", ptr: " + actionPtr.ToInt32());
            var error = new GetSocialError().ParseFromJson(serializedError);

            IOSUtils.TriggerCallback(actionPtr, error);
        }
        public static void OnGlobalError(IntPtr onGlobalErrorActionPtr, string serializedError)
        {
            GetSocialDebugLogger.D("OnGlobalError : " + serializedError);
            var error = new GetSocialError().ParseFromJson(serializedError);

            IOSUtils.TriggerCallback(onGlobalErrorActionPtr, error);
        }
        void onConflict(AndroidJavaObject conflictUserAJO)
        {
            GetSocialDebugLogger.D("AddAuthIdentityCallbackProxy onConflict");

            var conflictUser = new ConflictUser().ParseFromAJO(conflictUserAJO);

            HandleValue(conflictUser, _onConflict);
        }
Ejemplo n.º 4
0
 public static void ActionCallback(IntPtr actionPtr)
 {
     GetSocialDebugLogger.D("CompleteCallback");
     if (actionPtr != IntPtr.Zero)
     {
         actionPtr.Cast <Action>().Invoke();
     }
 }
Ejemplo n.º 5
0
 public static void FailureWithDataCallback(IntPtr actionPtr, string data, string errorMessage)
 {
     GetSocialDebugLogger.D("FailureWithDataCallback: " + errorMessage + ", data: " + data);
     if (actionPtr != IntPtr.Zero)
     {
         actionPtr.Cast <Action <string, string> >().Invoke(data, errorMessage);
     }
 }
Ejemplo n.º 6
0
 public static void PushTokenListener(IntPtr actionPtr, string dataStr)
 {
     GetSocialDebugLogger.D("PushToken: " + dataStr);
     if (actionPtr != IntPtr.Zero)
     {
         actionPtr.Cast <PushTokenListener>().Invoke(dataStr);
     }
 }
        void onSuccess(AndroidJavaObject referralDataAJO)
        {
            var referralData = new ReferralData().ParseFromAJO(referralDataAJO);

            GetSocialDebugLogger.D("On success: " + referralData);

            HandleValue(referralData, _onSuccess);
        }
        void onSuccess(AndroidJavaObject resultAJO)
        {
            var res = new T().ParseFromAJO(resultAJO);

            GetSocialDebugLogger.D("On success: " + res);

            HandleValue(res, _onSuccess);
        }
Ejemplo n.º 9
0
        public static Dictionary <string, object> ToDict(this string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                GetSocialDebugLogger.W("Trying to deserialize empty or null string as dictionary");
                return(new Dictionary <string, object>());
            }

            return(GSJson.Deserialize(json) as Dictionary <string, object>);
        }
Ejemplo n.º 10
0
        public static void FetchReferralDataCallback(IntPtr actionPtr, string referralData)
        {
            GetSocialDebugLogger.D("OnReferralDataReceived: " + referralData);
            ReferralData data = null;

            if (!string.IsNullOrEmpty(referralData))
            {
                data = new ReferralData().ParseFromJson(referralData.ToDict());
            }
            IOSUtils.TriggerCallback(actionPtr, data);
        }
Ejemplo n.º 11
0
 public static void CallStaticSafe(this AndroidJavaObject ajo, string methodName,
                                   params object[] args)
 {
     try
     {
         ajo.CallStatic(methodName, args);
     }
     catch (Exception e)
     {
         GetSocialDebugLogger.Ex(e, string.Format("Failed to call {0} on {1}", methodName, ajo.GetClassName()));
     }
 }
Ejemplo n.º 12
0
 public static void CallSafe(this AndroidJavaObject ajo, string methodName,
                             params object[] args)
 {
     try
     {
         ajo.Call(methodName, args);
     }
     catch (Exception exception)
     {
         GetSocialDebugLogger.Ex(exception, string.Format("Failed to call {0} because of: {1}", methodName, exception.Message));
     }
 }
Ejemplo n.º 13
0
        public static T Parse <T>(string json) where T : IConvertableFromNative <T>, new()
        {
            T result = new T();

            if (string.IsNullOrEmpty(json))
            {
                // return immediately in case of unexpected empty/null json
                GetSocialDebugLogger.E("ParseList is parsing null or empty json string");
                return(result);
            }

            return(result.ParseFromJson(json.ToDict()));
        }
        protected void HandleError(AndroidJavaObject throwable, Action <GetSocialError> onFailure)
        {
            if (onFailure == null)
            {
                return;
            }

            using (throwable)
            {
                var ex = throwable.ToGetSocialError();
                GetSocialDebugLogger.D(GetType().Name + " onFailure: " + ex);
                ExecuteOnMainThread(() => onFailure(ex));
            }
        }
Ejemplo n.º 15
0
        public static bool NotificationListener(IntPtr funcPtr, string dataStr)
        {
            GetSocialDebugLogger.D("NotificationReceived: " + dataStr);
            var data                   = dataStr.ToDict();
            var wasClicked             = (bool)data["wasClicked"];
            var notification           = (string)data["notification"];
            var notificationDictionary = notification.ToDict();
            var notificationEntity     = new Notification().ParseFromJson(notificationDictionary);

            if (funcPtr != IntPtr.Zero)
            {
                return(funcPtr.Cast <NotificationListener>().Invoke(notificationEntity, wasClicked));
            }
            return(false);
        }
Ejemplo n.º 16
0
        private static void HandleAndroidJavaObjectCallException <T>(AndroidJavaObject ajo, string methodName,
                                                                     Exception exception)
        {
            // If we call method that return null from Java an exception will be thrown. So we have to ignore most part of them.
            // Related Unity issue: https://issuetracker.unity3d.com/issues/androidjavaobject-dot-call-throws-exception-instead-of-returning-null-pointer
            // Fixed in Unity 5.6.0
            var isExceptionCausedByNullObjectReturnedFromJava =
                typeof(T) == typeof(AndroidJavaObject) &&
                exception.Message.Contains("AndroidJavaObject with null ptr");

            if (!isExceptionCausedByNullObjectReturnedFromJava)
            {
                GetSocialDebugLogger.Ex(exception,
                                        string.Format("Failed to call {0} on {1}", methodName, ajo));
            }
        }
Ejemplo n.º 17
0
        public static Dictionary <string, TValue> ParseDictionary <TValue>(string json)
            where TValue : IConvertableFromNative <TValue>, new()
        {
            var result = new Dictionary <string, TValue>();

            if (string.IsNullOrEmpty(json))
            {
                // return immediately in case of unexpected empty/null json
                GetSocialDebugLogger.E("ParseDictionary is parsing null or empty json string");
                return(result);
            }

            var stringDict = ParseDictionary(json);

            foreach (var keyValuePairs in stringDict)
            {
                result.Add(keyValuePairs.Key, Parse <TValue>(keyValuePairs.Value));
            }
            return(result);
        }
Ejemplo n.º 18
0
        public static Dictionary <string, T> ParseDictionary <T>(string json)
            where T : IConvertableFromNative <T>, new()
        {
            var result = new Dictionary <string, T>();

            if (string.IsNullOrEmpty(json))
            {
                // return immediately in case of unexpected empty/null json
                GetSocialDebugLogger.E("ParseDictionary is parsing null or empty json string");
                return(result);
            }

            var objectDict = ToDict(json);

            foreach (var keyValuePairs in objectDict)
            {
                T value = new T();
                result.Add(keyValuePairs.Key, value.ParseFromJson((Dictionary <string, object>)keyValuePairs.Value));
            }
            return(result);
        }
Ejemplo n.º 19
0
        public static List <T> ParseList <T>(string json) where T : IConvertableFromNative <T>, new()
        {
            var result = new List <T>();

            if (string.IsNullOrEmpty(json))
            {
                // return immediately in case of unexpected empty/null json
                GetSocialDebugLogger.E("ParseList is parsing null or empty json string");
                return(result);
            }


            var entities = GSJson.Deserialize(json) as List <object>;

            if (entities == null)
            {
                return(result);
            }
            return(entities
                   .ConvertAll(item => item as Dictionary <string, object>)
                   .ConvertAll(entity => new T().ParseFromJson(entity)));
        }
 void onComplete()
 {
     GetSocialDebugLogger.D("AddAuthIdentityCallbackProxy onComplete");
     ExecuteOnMainThread(_onComplete);
 }
 void onSuccess()
 {
     GetSocialDebugLogger.D("CompletionCallback success");
     ExecuteOnMainThread(_onSuccess);
 }
Ejemplo n.º 22
0
 public static void BoolCallback(IntPtr actionPtr, bool result)
 {
     GetSocialDebugLogger.D("BoolCallback: " + result);
     IOSUtils.TriggerCallback(actionPtr, result);
 }
Ejemplo n.º 23
0
 public static void StringCallback(IntPtr actionPtr, string result)
 {
     GetSocialDebugLogger.D("StringResultCallaback: " + result);
     IOSUtils.TriggerCallback(actionPtr, result);
 }
Ejemplo n.º 24
0
 public static void IntCallback(IntPtr actionPtr, int result)
 {
     GetSocialDebugLogger.D("IntCallback: " + result);
     IOSUtils.TriggerCallback(actionPtr, result);
 }