コード例 #1
0
    // Local Notifacations

    // This will use the info from the inspector - Not very helpfull in my eyes but putting it here anyways just incase;
    public void BuildSimpleNotifacation()
    {
        AndroidNotificationBuilder builder = new AndroidNotificationBuilder(
            SA.Common.Util.IdFactory.NextId, "Local Notification Title", "This is local notification", 10);

        AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
    }
コード例 #2
0
    private void Local()
    {
        AndroidNotificationBuilder builder = new AndroidNotificationBuilder(SA.Common.Util.IdFactory.NextId,
                                                                            "Local Notification Title",
                                                                            "This is local notification",
                                                                            10);

        builder.SetBigPicture(bigPicture);
        AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
    }
コード例 #3
0
	private void Local() {
		//LastNotificationId = AndroidNotificationManager.instance.ScheduleLocalNotification("Hello", "This is local notification", 5);

		AndroidNotificationBuilder builder = new AndroidNotificationBuilder(SA_IdFactory.NextId,
		                                                                    "Local Notification Title",
		                                                                    "Big Picture Style Notification for AndroidNative Preview",
		                                                                    3);
		builder.SetBigPicture (bigPicture);
		AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
	}
コード例 #4
0
    public void ShowLocalNotifacation(string id)
    {
        GetNotifacationByName(id);
        AndroidNotificationBuilder builder = new AndroidNotificationBuilder(currentNotifacation.notifacationID, currentNotifacation.title, currentNotifacation.body, currentNotifacation.timer);

        builder.SetIconName(currentNotifacation.iconName);
        builder.SetVibration(currentNotifacation.vibrate);
        builder.SetSoundName(currentNotifacation.notifaacationSoundName);
        AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
    }
コード例 #5
0
    public static int RegisterNotification(int id, DateTime fireDate, string body)
    {
        if (fireDate < UnbiasedTime.Instance.Now())              // fire date is in past
        {
            return(-1);
        }

        // notifications are disabled
        if (PreferencesFactory.GetInt(Constants.KeyNotificationsAllowed, 1) == 0)
        {
            return(-1);
        }

#if UNITY_IPHONE
        NotificationCenter.RequestPermissions((result) =>
        {
            PreferencesFactory.SetInt(Constants.KeyNotificationsAllowed, result.IsSucceeded ? 1 : 0);

            //Debug.Log("RequestPermissions callback: err: " + (result.HasError ? result.Error.Message : null) + "; success: " + result.IsSucceeded + "; failed: " + result.IsFailed);
        });

        var content = new NotificationContent();
        content.Body  = body;
        content.Badge = 1;

        var dateComponents = new DateComponents()
        {
            Year   = fireDate.Year,
            Month  = fireDate.Month,
            Day    = fireDate.Day,
            Hour   = fireDate.Hour,
            Minute = fireDate.Minute,
            Second = fireDate.Second
        };

        var trigger = new CalendarTrigger(dateComponents);
        var request = new NotificationRequest(id.ToString(), content, trigger);

        NotificationCenter.AddNotificationRequest(request, (result) => {
            //Debug.Log("AddNotificationRequest callback: err: " + (result.HasError ? result.Error.Message : null) + "; success: " + result.IsSucceeded + "; failed: " + result.IsFailed);
        });
                #endif

                #if UNITY_ANDROID
        TimeSpan delay = fireDate - UnbiasedTime.Instance.Now();
        AndroidNotificationBuilder builder = new AndroidNotificationBuilder(id,
                                                                            GameManager.Instance.GameName,
                                                                            body,
                                                                            (int)delay.TotalSeconds);

        AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
                #endif

        return(id);
    }
コード例 #6
0
    private void Local()
    {
        //LastNotificationId = AndroidNotificationManager.instance.ScheduleLocalNotification("Hello", "This is local notification", 5);

        AndroidNotificationBuilder builder = new AndroidNotificationBuilder(SA_IdFactory.NextId,
                                                                            "Local Notification Title",
                                                                            "Big Picture Style Notification for AndroidNative Preview",
                                                                            3);

        builder.SetBigPicture(bigPicture);
        AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
    }
コード例 #7
0
	public static void ScheduleLocalNotification(AndroidNotificationBuilder builder) {
		CallActivityFunction("ScheduleLocalNotification",
		                     builder.Title,
		                     builder.Message,
		                     builder.Time.ToString(),
		                     builder.Id.ToString(),
		                     builder.Icon,
		                     builder.Sound,
		                     builder.Vibration.ToString(),
		                     builder.ShowIfAppForeground.ToString(),
		                     builder.LargeIcon);
	}
コード例 #8
0
	public static void ScheduleLocalNotification(AndroidNotificationBuilder builder) {
		CallActivityFunction("ScheduleLocalNotification",
		                     builder.Title,
		                     builder.Message,
		                     builder.Time.ToString(),
		                     builder.Id.ToString(),
		                     builder.Icon,
		                     builder.Sound,
		                     builder.Vibration.ToString(),
		                     builder.ShowIfAppForeground.ToString(),
		                     builder.LargeIcon,
		                     builder.BigPicture == null ? string.Empty : System.Convert.ToBase64String(builder.BigPicture.EncodeToPNG()));
	}
コード例 #9
0
 public static void ScheduleLocalNotification(AndroidNotificationBuilder builder)
 {
     CallActivityFunction("ScheduleLocalNotification",
                          builder.Title,
                          builder.Message,
                          builder.Time.ToString(),
                          builder.Id.ToString(),
                          builder.Icon,
                          builder.Sound,
                          builder.Vibration.ToString(),
                          builder.ShowIfAppForeground.ToString(),
                          builder.LargeIcon);
 }
コード例 #10
0
    public int ScheduleLocalNotification(AndroidNotificationBuilder builder)
    {
        AN_NotificationProxy.ScheduleLocalNotification(builder);

        LocalNotificationTemplate        notification = new LocalNotificationTemplate(builder.Id, builder.Title, builder.Message, DateTime.Now.AddSeconds(builder.Time));
        List <LocalNotificationTemplate> scheduled    = LoadPendingNotifications();

        scheduled.Add(notification);

        SaveNotifications(scheduled);

        return(builder.Id);
    }
コード例 #11
0
 public static void ScheduleLocalNotification(AndroidNotificationBuilder builder)
 {
     CallActivityFunction("ScheduleLocalNotification",
                          builder.Title,
                          builder.Message,
                          builder.Time.ToString(),
                          builder.Id.ToString(),
                          builder.Icon,
                          builder.Sound,
                          builder.Vibration.ToString(),
                          builder.ShowIfAppForeground.ToString(),
                          builder.LargeIcon,
                          builder.BigPicture == null ? string.Empty : System.Convert.ToBase64String(builder.BigPicture.EncodeToPNG()));
 }
コード例 #12
0
 public int AddLocalNotificationBySeconds(string title, string msg, int seconds)
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         int next_id = AndroidNotificationManager.Instance.GetNextId;
         AndroidNotificationBuilder builder = new AndroidNotificationBuilder(next_id, title, msg, seconds);
         builder.SetLargeIcon("pushicon_72x72");
         builder.SetIconName("pushicon_36x36");
         return(AndroidNotificationManager.Instance.ScheduleLocalNotification(builder));
     }
     else
     {
         return(UM_NotificationController.Instance.ScheduleLocalNotification(title, msg, seconds));
     }
 }
コード例 #13
0
    private void PostAndroidGroupNotification(DateTime _time, string message)
    {
        System.DateTime            now          = System.DateTime.Now;
        System.TimeSpan            delayToGroup = _time - now;
        var                        timeto       = (int)delayToGroup.TotalSeconds;
        AndroidNotificationBuilder builder      = new AndroidNotificationBuilder(SA.Common.Util.IdFactory.NextId,
                                                                                 "Bookvik",
                                                                                 message,
                                                                                 timeto); // The notification will be fired up in ten seconds after schedule

        builder.SetRepeating(true);

        System.TimeSpan delayToNextDay = now.AddDays(1.0f) - now;
        builder.SetRepeatDelay((int)delayToNextDay.TotalSeconds); // Set everyday repeating local notification

        AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
    }
コード例 #14
0
	public static void ScheduleLocalNotification(AndroidNotificationBuilder builder) {
		CallActivityFunction("ScheduleLocalNotification",
		                     builder.Title,
		                     builder.Message,
		                     builder.Time.ToString(),
		                     builder.Id.ToString(),
		                     builder.Icon,
		                     builder.Sound,
		                     builder.Vibration.ToString(),
		                     builder.ShowIfAppForeground.ToString(),
		                     builder.LargeIcon,
		                     builder.BigPicture == null ? string.Empty : System.Convert.ToBase64String(builder.BigPicture.EncodeToPNG()),
							 builder.Color == null ? string.Empty : string.Format("{0}|{1}|{2}|{3}", 255 * builder.Color.Value.a,
		                                                     										 255 * builder.Color.Value.r,
		                                                     										 255 * builder.Color.Value.g,
		                                                     										 255 * builder.Color.Value.b),
		                     builder.WakeLockTime);
	}
コード例 #15
0
 public static void ScheduleLocalNotification(AndroidNotificationBuilder builder)
 {
     CallActivityFunction("ScheduleLocalNotification",
                          builder.Title,
                          builder.Message,
                          builder.Time.ToString(),
                          builder.Id.ToString(),
                          builder.Icon,
                          builder.Sound,
                          builder.Vibration.ToString(),
                          builder.ShowIfAppForeground.ToString(),
                          builder.Repeating,
                          builder.RepeatDelay,
                          builder.LargeIcon,
                          builder.BigPicture == null ? string.Empty : System.Convert.ToBase64String(builder.BigPicture.EncodeToPNG()),
                          builder.Color == null ? string.Empty : string.Format("{0}|{1}|{2}|{3}", 255 * builder.Color.Value.a,
                                                                               255 * builder.Color.Value.r,
                                                                               255 * builder.Color.Value.g,
                                                                               255 * builder.Color.Value.b),
                          builder.WakeLockTime);
 }
コード例 #16
0
    public int ScheduleLocalNotification(string title, string message, int seconds)
    {
        AndroidNotificationBuilder builder = new AndroidNotificationBuilder(GetNextId, title, message, seconds);

        return(ScheduleLocalNotification(builder));
    }
コード例 #17
0
	private void Local(int time) {
		//LastNotificationId = AndroidNotificationManager.instance.ScheduleLocalNotification("Hello", "This is local notification", 5);
		
		AndroidNotificationBuilder builder = new AndroidNotificationBuilder(SA_IdFactory.NextId,
		                                                                    "Zombie Cross",
		                                                                    "You have now 20 lives, go to kill zombies",
		                                                                    time);
		//bigPicture = (Texture2D)Resources.Load("images/logoplaystore.png", typeof(Texture2D));
		//(GameObject)Resources.Load("prefabs/CFXM2_Soul", typeof(GameObject));
		builder.SetBigPicture (bigPicture);
		AndroidNotificationManager.Instance.ScheduleLocalNotification(builder);
		//AndroidNotificationManager.Instance.ScheduleLocalNotification("Zombie Cross","You have now 20 lives, go to kill zombies",time);
	}