ToString() public method

public ToString ( ) : string
return string
Ejemplo n.º 1
0
        public IEnumerator SendCoroutine()
        {
            AddDefaultParameters();

            WWWForm requestForm = new WWWForm ();
            requestForm.AddField ("name", this.eventName);
            requestForm.AddField ("data", this.data.ToString ());
            if (!this.customData.IsNull) {
                requestForm.AddField ("customData", this.customData.Print(false));
            } else {
                requestForm.AddField ("customData", "{}");
            }

            requestForm.AddField ("ts", "1470057439857");
            requestForm.AddField ("queued", 0);
            requestForm.AddField ("debugMode", "true");

            WWW request = new WWW ("https://apptracker.spilgames.com/v1/native-events/event/android/" + Spil.BundleIdEditor + "/" + this.eventName, requestForm);
            yield return request;
            //			while (!request.isDone);
            if (request.error != null) {
                Debug.LogError ("Error getting data: " + request.error);
                Debug.LogError ("Error getting data: " + request.text);
            } else {
                JSONObject serverResponse = new JSONObject (request.text);
                Debug.Log ("Data returned: " + serverResponse.ToString());
                ResponseEvent.Build(serverResponse);
            }
        }
		private void CheckForRemoteNotifications()
		{
	bool proccessedNotifications = false;
	#if UNITY_IPHONE
	#if UNITY_5
			if (UnityEngine.iOS.NotificationServices.remoteNotificationCount > 0)
			{			
				foreach(UnityEngine.iOS.RemoteNotification notification in 	UnityEngine.iOS.NotificationServices.remoteNotifications)
				{
	#else
	if (UnityEngine.NotificationServices.remoteNotificationCount > 0)
	{			
	foreach(UnityEngine.RemoteNotification notification in 	UnityEngine.NotificationServices.remoteNotifications)
	{
	#endif
					foreach(var key in notification.userInfo.Keys)
					{
						if(notification.userInfo[key].GetType() == typeof(Hashtable))
						{
							Hashtable userInfo = (Hashtable) notification.userInfo[key];
							JSONObject notificationPayload = new JSONObject();
							foreach(var pKey in userInfo.Keys)
							{
								if(userInfo[pKey].GetType() == typeof(string))
								{
									string keyStr = pKey.ToString();
									string value = userInfo[pKey].ToString();
									notificationPayload.AddField(keyStr,value);
								}
								if(userInfo[pKey].GetType() == typeof(Hashtable))
								{
									JSONObject innerJson = new JSONObject();
									Hashtable innerTable = (Hashtable)userInfo[pKey];
									foreach(var iKey in innerTable.Keys)
									{
										string iKeyStr = iKey.ToString();
										if(innerTable[iKey].GetType() == typeof(Hashtable))
										{
											Hashtable innerTableB = (Hashtable)innerTable[iKey];
											JSONObject innerJsonB = new JSONObject();
											foreach(var bKey in innerTableB.Keys)
											{
												innerJsonB.AddField(bKey.ToString(),innerTableB[bKey].ToString());
											}
											innerJson.AddField(iKeyStr,innerJsonB);
										}
										if(innerTable[iKey].GetType() == typeof(string))
										{
											string iValue = innerTable[iKey].ToString();
											innerJson.AddField(iKeyStr,iValue);
										}
									}
									string keyStr = pKey.ToString();
									notificationPayload.AddField(keyStr,innerJson);
								}
							}

							String notificationJsonForNative = notificationPayload.ToString().Replace("'","\"");
							if(!proccessedNotifications){									
								SendCustomEvent("notificationReceived", new Dictionary<string, string>() { { "notificationPayload", notificationJsonForNative}});
								proccessedNotifications = true;
							}
						}
					}
				}
	#if UNITY_5
				UnityEngine.iOS.NotificationServices.ClearRemoteNotifications();
	#else
	UnityEngine.NotificationServices.ClearRemoteNotifications();
	#endif
			} else {
				Debug.Log("NO REMOTE NOTIFICATIONS FOUND");
			}
	#endif
		}
		/// <summary>
		/// This method is marked as internal and should not be exposed to developers.
		/// The Spil Unity SDK is not packaged as a seperate assembly yet so this method is currently visible, this will be fixed in the future.
		/// Internal method names start with a lower case so you can easily recognise and avoid them.
		/// </summary>
		internal override void SpilInit()
		{
			JSONObject options = new JSONObject();
			options.AddField ("isUnity",true);
			initEventTrackerWithOptions(options.ToString());
			applicationDidBecomeActive();

            if (disableAutomaticRegisterForPushNotifications == false) 
			{
                RegisterForPushNotifications ();
				CheckForRemoteNotifications();
			}
		}