コード例 #1
0
    private VoxelBusters.NativePlugins.CrossPlatformNotification CreateNotification(long _fireAfterSec, VoxelBusters.NativePlugins.eNotificationRepeatInterval _repeatInterval)
    {
        // User info
        IDictionary _userInfo = new Dictionary <string, string>();

        _userInfo["data"] = "custom data";

        VoxelBusters.NativePlugins.CrossPlatformNotification.iOSSpecificProperties _iosProperties = new VoxelBusters.NativePlugins.CrossPlatformNotification.iOSSpecificProperties();
        _iosProperties.HasAction   = true;
        _iosProperties.AlertAction = "alert action";

        VoxelBusters.NativePlugins.CrossPlatformNotification.AndroidSpecificProperties _androidProperties = new VoxelBusters.NativePlugins.CrossPlatformNotification.AndroidSpecificProperties();
        _androidProperties.ContentTitle = "Daily Quote";
        _androidProperties.TickerText   = "Check your new daily quote for today";
        _androidProperties.LargeIcon    = "icon.png";         //Keep the files in Assets/PluginResources/Android or Common folder.

        VoxelBusters.NativePlugins.CrossPlatformNotification _notification = new VoxelBusters.NativePlugins.CrossPlatformNotification();
        _notification.AlertBody         = "Check your new daily quote for today";                 //On Android, this is considered as ContentText
        _notification.FireDate          = System.DateTime.Now.AddSeconds(_fireAfterSec);
        _notification.RepeatInterval    = _repeatInterval;
        _notification.SoundName         = "Notification.mp3";                 //Keep the files in Assets/PluginResources/Android or iOS or Common folder.
        _notification.UserInfo          = _userInfo;
        _notification.iOSProperties     = _iosProperties;
        _notification.AndroidProperties = _androidProperties;

        return(_notification);
    }
コード例 #2
0
        private void DidReceiveLocalNotification(CrossPlatformNotification _notification)
        {
            Console.Log(Constants.kDebugTag, "[NotificationService] Received new local notification");

            if (DidReceiveLocalNotificationEvent != null)
                DidReceiveLocalNotificationEvent(_notification);
        }
		protected override void ParseAppLaunchInfo (string _launchData, out CrossPlatformNotification _launchLocalNotification, out CrossPlatformNotification _launchRemoteNotification)
		{
			Dictionary<string, object> 	_payloadDict		= JSONUtility.FromJSON(_launchData) as Dictionary<string, object>;
			
			object						_isRemoteNotification = "false";

			if(_payloadDict != null)
			{
				_payloadDict.TryGetValue(AndroidNotificationPayload.kIsRemoteNotification, out _isRemoteNotification);
	
				Debug.LogError("Launch Notification  is Remote Notification ? " + _isRemoteNotification);
				// Launched with local notification
				if (_isRemoteNotification.Equals("false"))
				{
					_launchLocalNotification	= new AndroidNotificationPayload((IDictionary)_payloadDict);
					_launchRemoteNotification	= null;
				}
				// Launched with remote notification
				else
				{
					_launchLocalNotification	= null;
					_launchRemoteNotification	= new AndroidNotificationPayload((IDictionary)_payloadDict);
				}
			}
			// Normal launch
			else
			{
				_launchLocalNotification	= null;
				_launchRemoteNotification	= null;
			}
		}
コード例 #4
0
		public override string ScheduleLocalNotification (CrossPlatformNotification _notification)
		{
			// Append notification id to user info
			string _notificationID				= _notification.GenerateNotificationID();
			
			// Assign notification data
			LocalNotification _newNotification	= new LocalNotification();
			_newNotification.alertBody			= _notification.AlertBody;
			_newNotification.fireDate			= _notification.FireDate;
			_newNotification.repeatInterval		= iOSNotificationPayload.ConvertToCalendarUnit(_notification.RepeatInterval);
			_newNotification.userInfo			= _notification.UserInfo;
			
			// iOS Notification additional data
			CrossPlatformNotification.iOSSpecificProperties _iOSProperties	= _notification.iOSProperties;
			
			if (_iOSProperties != null)
			{
				_newNotification.hasAction					= _iOSProperties.HasAction;
				_newNotification.applicationIconBadgeNumber	= _iOSProperties.BadgeCount;
				
				if (!string.IsNullOrEmpty(_iOSProperties.AlertAction))
					_newNotification.alertAction		= _iOSProperties.AlertAction;
				
				if (!string.IsNullOrEmpty(_iOSProperties.LaunchImage))
					_newNotification.alertLaunchImage	= _iOSProperties.LaunchImage;
				
				if (!string.IsNullOrEmpty(_iOSProperties.SoundName))
					_newNotification.soundName			= _iOSProperties.SoundName;
			}

			// Schedule notification
			NotificationServices.ScheduleLocalNotification(_newNotification);
			return _notificationID;
		}
コード例 #5
0
		public override string ScheduleLocalNotification (CrossPlatformNotification _notification)
		{
			// Append notification id to userinfo
			string _notificationID	= _notification.GenerateNotificationID();

			// Scheduling new notification
			m_notificationCenter.ScheduleLocalNotification(_notification);

			return _notificationID;
		}
コード例 #6
0
		public override string ScheduleLocalNotification (CrossPlatformNotification _notification)
		{
			// Append notification id to user info
			string _notificationID	= _notification.GenerateNotificationID();
			string _payload			= iOSNotificationPayload.CreateNotificationPayload(_notification).ToJSON();

			// Schedule notification
			scheduleLocalNotification(_payload);

			return _notificationID;
		}
コード例 #7
0
		public override string ScheduleLocalNotification (CrossPlatformNotification _notification)
		{
			string _notificationID		= _notification.GenerateNotificationID();

			// Create meta info and pass to native
			IDictionary _payLoadInfo	= AndroidNotificationPayload.CreateNotificationPayload(_notification);

			// Scheduling notification
			Plugin.Call(NativeInfo.Methods.SCHEDULE_LOCAL_NOTIFICATION, _payLoadInfo.ToJSON());
			
			return _notificationID;
		}
コード例 #8
0
	private void DidReceiveRemoteNotificationEvent (CrossPlatformNotification _notification)
	{
		IDictionary _userInfo 			= _notification.UserInfo;
		if (_userInfo != null) {
			//(string)_userInfo["notifType"] == "chat"
		}

		string[] m_buttons = new string[] { "Cerrar", "Ver" };
		NPBinding.UI.ShowAlertDialogWithMultipleButtons ("Tienes una nueva notificación", _notification.AlertBody, m_buttons, (string _buttonPressed)=>{
			if(_buttonPressed == "Ver"){

				//Application.LoadLevel ("notificaciones");
			}
		});
	}
		protected override void ParseAppLaunchInfo (string _launchData, out CrossPlatformNotification _launchLocalNotification, out CrossPlatformNotification _launchRemoteNotification)
		{
			Dictionary<string, object> 	_launchDataDict		= JSONUtility.FromJSON(_launchData) as Dictionary<string, object>;
			object						_payloadDict		= null;

			// Launched with local notification
			if (_launchDataDict.TryGetValue(kAppLaunchLocalNotification, out _payloadDict))
			{
				_launchLocalNotification	= new iOSNotificationPayload((IDictionary)_payloadDict);
				_launchRemoteNotification	= null;
			}
			// Launched with remote notification
			else if (_launchDataDict.TryGetValue(kAppLaunchRemoteNotification, out _payloadDict))
			{
				_launchLocalNotification	= null;
				_launchRemoteNotification	= new iOSNotificationPayload((IDictionary)_payloadDict);
			}
			// Normal launch
			else
			{
				_launchLocalNotification	= null;
				_launchRemoteNotification	= null;
			}
		}
コード例 #10
0
		private void DidLaunchWithRemoteNotificationEvent (CrossPlatformNotification _notification)
		{
			AddNewResult("Application did launch with remote notification.");
			AppendNotificationResult(_notification);
		}
コード例 #11
0
	private void DidLaunchWithRemoteNotificationEvent (CrossPlatformNotification _notification)
	{

	}
コード例 #12
0
		private void DidReceiveLocalNotificationEvent (CrossPlatformNotification _notification)
		{
			AddNewResult("Application received local notification.");
			AppendNotificationResult(_notification);
		}
コード例 #13
0
		protected virtual void ParseAppLaunchInfo (string _launchData, out CrossPlatformNotification _launchLocalNotification, out CrossPlatformNotification _launchRemoteNotification)
		{
			_launchLocalNotification	= null;
			_launchRemoteNotification	= null;
		}
コード例 #14
0
ファイル: chatTest.cs プロジェクト: georgex1/rednit
	private string ScheduleLocalNotification(CrossPlatformNotification _notification)
	{
		return NPBinding.NotificationService.ScheduleLocalNotification(_notification);
	}
コード例 #15
0
		private void DidLaunchWithLocalNotificationEvent (CrossPlatformNotification _notification)
		{
			AddNewResult("Received DidLaunchWithLocalNotificationEvent");
			AppendNotificationResult(_notification);
		}
コード例 #16
0
		void AppendNotificationResult (CrossPlatformNotification _notification)
		{
			string _alert 					= _notification.AlertBody;

#pragma warning disable
			// Exists only for local notifications which will be useful if we need to cancel a local notification
			string _notificationIdentifier 	= _notification.GetNotificationID();
#pragma warning restore
			
			//Get UserInfo details
			IDictionary _userInfo 			= _notification.UserInfo;
			
			//Can get specific details of a notification based on platform
			/*
					//For Android
					_notification.AndroidProperties.ContentTitle
					_notification.AndroidProperties.TickerText

					//For iOS
					_notification.iOSProperties.AlertAction;
					_notification.iOSProperties.BadgeCount;
				*/
			
			// Append to result list
			AppendResult("Alert = " + _alert);

			// Append user info
			string _userInfoDetails = null;

			if (_userInfo != null)
			{
				// Initialize and iterate through the list
				_userInfoDetails	= string.Empty;

				foreach (string _key in _userInfo.Keys)
				{
					_userInfoDetails	+= _key + " : " + _userInfo[_key] + "\n";
				}
			}
			else
			{
				_userInfoDetails	= "NULL";
			}

			AppendResult("UserInfo = " + _userInfoDetails);	
		}
コード例 #17
0
		protected virtual void ParseNotificationPayloadData (string _payload, out CrossPlatformNotification _notification)
		{
			_notification				= CrossPlatformNotification.CreateNotificationFromPayload(_payload);
		}
コード例 #18
0
		private void DidReceiveAppLaunchInfo (CrossPlatformNotification _launchLocalNotification, CrossPlatformNotification _launchRemoteNotification)
		{
			m_receivedAppLaunchInfo		= true;
			m_launchLocalNotification	= _launchLocalNotification;
			m_launchRemoteNotification	= _launchRemoteNotification;
		}
コード例 #19
0
		private CrossPlatformNotification CreateNotification (long _fireAfterSec, eNotificationRepeatInterval _repeatInterval)
		{
			// User info
			IDictionary _userInfo			= new Dictionary<string, string>();
			_userInfo["data"]				= "add what is required";
			
			CrossPlatformNotification.iOSSpecificProperties _iosProperties			= new CrossPlatformNotification.iOSSpecificProperties();
			_iosProperties.HasAction		= true;
			_iosProperties.AlertAction		= "alert action";
			
			CrossPlatformNotification.AndroidSpecificProperties _androidProperties	= new CrossPlatformNotification.AndroidSpecificProperties();
			_androidProperties.ContentTitle	= "content title";
			_androidProperties.TickerText	= "ticker ticks over here";
			_androidProperties.CustomSound	= "Notification.mp3"; //Keep the files in Assets/StreamingAssets/VoxelBusters/NativePlugins/Android folder.
			_androidProperties.LargeIcon	= "NativePlugins.png"; //Keep the files in Assets/StreamingAssets/VoxelBusters/NativePlugins/Android folder.
			
			CrossPlatformNotification _notification	= new CrossPlatformNotification();
			_notification.AlertBody			= "alert body"; //On Android, this is considered as ContentText
			_notification.FireDate			= System.DateTime.Now.AddSeconds(_fireAfterSec);
			_notification.RepeatInterval	= _repeatInterval;
			_notification.UserInfo			= _userInfo;
			_notification.iOSProperties		= _iosProperties;
			_notification.AndroidProperties	= _androidProperties;

			return _notification;
		}
コード例 #20
0
ファイル: notifications.cs プロジェクト: georgex1/rednit
	private void DidReceiveRemoteNotificationEvent (CrossPlatformNotification _notification)
	{
		Debug.Log("Received DidReceiveRemoteNotificationEvent : " + _notification.ToString());
		//string[] 	m_buttons				= new string[] { "Cancelar", "Ver" };
		//NPBinding.UI.ShowAlertDialogWithMultipleButtons("Alerta!", _notification.AlertBody, m_buttons, MultipleButtonsAlertClosed); 
	}
コード例 #21
0
		private void DidReceiveRemoteNotificationEvent (CrossPlatformNotification _notification)
		{
			AddNewResult("Received DidReceiveRemoteNotificationEvent");
			AppendNotificationResult(_notification);
		}
コード例 #22
0
ファイル: notifications.cs プロジェクト: georgex1/rednit
	/*private void MultipleButtonsAlertClosed (string _buttonPressed)
	{
		if (_buttonPressed == "Ver") {
			//GMS.call_updates ("notificaciones");
			Application.LoadLevel ("amigos");
		}
	}*/

	private void DidLaunchWithRemoteNotificationEvent (CrossPlatformNotification _notification)
	{
		//GMS.call_updates ("notificaciones");
		Application.LoadLevel ("amigos");
	}
コード例 #23
0
ファイル: chatTest.cs プロジェクト: georgex1/rednit
	private CrossPlatformNotification CreateNotification (long _fireAfterSec, eNotificationRepeatInterval _repeatInterval)
	{
		// User info
		IDictionary _userInfo			= new Dictionary<string, string>();
		_userInfo["data"]				= "add what is required";
		
		CrossPlatformNotification.iOSSpecificProperties _iosProperties			= new CrossPlatformNotification.iOSSpecificProperties();
		_iosProperties.HasAction		= true;
		_iosProperties.AlertAction		= GMS.appName;
		
		CrossPlatformNotification.AndroidSpecificProperties _androidProperties	= new CrossPlatformNotification.AndroidSpecificProperties();
		_androidProperties.ContentTitle	= GMS.amigoData.nombre;
		_androidProperties.TickerText	= GMS.appName;
		_androidProperties.CustomSound	= "Notification.mp3"; //Keep the files in Assets/StreamingAssets/VoxelBusters/NativePlugins/Android folder.
		//_androidProperties.LargeIcon	= "NativePlugins.png"; //Keep the files in Assets/StreamingAssets/VoxelBusters/NativePlugins/Android folder.
		if (GMS.checkImageExists (GMS.amigoData.foto)) {
			_androidProperties.LargeIcon = Application.persistentDataPath + "/" + GMS.amigoData.foto;
		} else {
			_androidProperties.LargeIcon	= "default.jpg";
		}
		
		CrossPlatformNotification _notification	= new CrossPlatformNotification();
		_notification.AlertBody			= MgsTextNotif; //On Android, this is considered as ContentText
		_notification.FireDate			= System.DateTime.Now.AddSeconds(_fireAfterSec);
		_notification.RepeatInterval	= _repeatInterval;
		_notification.UserInfo			= _userInfo;
		_notification.iOSProperties		= _iosProperties;
		_notification.AndroidProperties	= _androidProperties;
		
		return _notification;
	}
コード例 #24
0
	private void DidReceiveLocalNotificationEvent (CrossPlatformNotification _notification)
	{
		Debug.Log("Received DidReceiveLocalNotificationEvent : " + _notification.ToString());
	}
コード例 #25
0
 /// <summary>
 /// Schedules a local notification.
 /// </summary>
 /// <returns>Notification ID that can be used to uniquely identify every scheduled notification.</returns>
 /// <param name="_notification">Notification to be scheduled.</param>
 public virtual string ScheduleLocalNotification(CrossPlatformNotification _notification)
 {
     return null;
 }
コード例 #26
0
 public abstract void OnRemoteNotificationReceived(CrossPlatformNotification _notification, bool _isLaunchNotification);