Example #1
0
 /// <summary>
 ///     The actual implementation of initialising the FeedHenry SDK. It is called when the Init method of each platform's
 ///     FHClient class called in.
 ///     This way it will guarantee the platform's specific assembly will be loaded so that the ServiceFinder can find the
 ///     correct implmenetation for some of the services.
 ///     (The Adaptation approach used here works for wp and xamarain android without the FHClient reference. However, due
 ///     to Xamarain IOS is using AOT compiler, we have to reference the FHClient class of the IOS SDK to make sure it will
 ///     be loaded during compile.)
 /// </summary>
 /// <returns>If Init is success or not</returns>
 /// <exception cref="FHException"></exception>
 protected static async Task<bool> Init()
 {
     var fhconfig = FHConfig.GetInstance();
     if (AppReady) return true;
     if (fhconfig.IsLocalDevelopment)
     {
         AppReady = true;
         var cloudJson = new JObject();
         cloudJson["url"] = fhconfig.GetHost();
         CloudProps = new CloudProps(cloudJson);
         return true;
     }
     var initRequest = new FHInitRequest {TimeOut = TimeOut};
     var initRes = await initRequest.ExecAsync();
     if (null != initRes.Error) throw initRes.Error;
     var resJson = initRes.GetResponseAsJObject();
     CloudProps = new CloudProps(resJson);
     AppReady = true;
     var initValue = resJson["init"];
     if (null != initValue)
     {
         SaveInitInfo(initValue.ToString());
     }
     return true;
 }
Example #2
0
        /// <summary>
        /// The actual implementation of initialising the FeedHenry SDK. It is called when the Init method of each platform's FHClient class called in. 
        /// This way it will guarantee the platform's specific assembly will be loaded so that the ServiceFinder can find the correct implmenetation for some of the services.
        /// (The Adaptation approach used here works for wp and xamarain android without the FHClient reference. However, due to Xamarain IOS is using AOT compiler, we have to reference the FHClient class of the IOS SDK to make sure it will be loaded during compile.)
        /// </summary>
        /// <returns>If Init is success or not</returns>
        /// <exception cref="FHException"></exception>
		protected static async Task<bool> Init()
        {
			FHConfig fhconfig = FHConfig.getInstance();
            if (!appReady)
            {
                if(fhconfig.IsLocalDevelopment){
                    appReady = true;
                    JObject cloudJson = new JObject();
                    cloudJson["url"] = fhconfig.GetHost();
                    cloudProps = new CloudProps(cloudJson);
                    return true;
                }
                FHInitRequest initRequest = new FHInitRequest();
                initRequest.TimeOut = timeout;
                FHResponse initRes = await initRequest.execAsync();
                if (null == initRes.Error)
                {
					JObject resJson = initRes.GetResponseAsJObject();
					cloudProps = new CloudProps (resJson);
                    appReady = true;
					JToken initValue = resJson["init"];
                    if (null != initValue)
                    {
                        SaveInitInfo(initValue.ToString());
                    }
                    return true;
                }
                else
                {
                    throw initRes.Error;
                }
            }
            else
            {
                return true;
            }
        }