コード例 #1
0
    /// <summary>
    /// 单次推送
    /// </summary>
    /// <param name="id">每一个不同的推送需要不同的id,如果相同就会出现几个推送文本什么都一样的错误</param>
    /// <param name="delay">推送延迟</param>
    /// <param name="title">标题</param>
    /// <param name="message">文本</param>
    /// <param name="bgColor">颜色</param>
    /// <param name="sound">声音</param>
    /// <param name="vibrate">震动</param>
    /// <param name="lights"></param>
    /// <param name="bigIcon">大图标</param>
    /// <param name="executeMode"></param>
    public static void SendNotification(int id, long delay, string title, string message, Color32 bgColor,
                                        bool sound     = true, bool vibrate = true, bool lights = true,
                                        string bigIcon = __BIGICON,
                                        NotificationExecuteMode executeMode = NotificationExecuteMode.Inexact)
    {
        DebugLog.Log("Title:" + title);

#if UNITY_ANDROID && !UNITY_EDITOR
        if (__MAINACTIVITYCLASSNAME == null)
        {
            DebugLog.LogError("ActiveName Error");

            return;
        }

        AndroidJavaClass pluginClass = new AndroidJavaClass(__FULLCLASSNAME);

        if (pluginClass != null)
        {
            pluginClass.CallStatic("SetNotification", id, delay * 1000L, title, message, message, sound ? 1 : 0,
                                   vibrate ? 1 : 0, lights ? 1 : 0, bigIcon,
                                   __SMALLICON, bgColor.r * 65536 + bgColor.g * 256 + bgColor.b,
                                   (int)executeMode, __MAINACTIVITYCLASSNAME);
        }
#endif
    }
コード例 #2
0
 public static void SendNotification(int id, long delay, string title, string message, Color32 bgColor, bool sound = true, bool vibrate = true, bool lights = true, string bigIcon = "", NotificationExecuteMode executeMode = NotificationExecuteMode.Inexact)
 {
     #if UNITY_ANDROID && !UNITY_EDITOR
     AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
     if (pluginClass != null)
     {
         pluginClass.CallStatic("SetNotification", id, unityClass, delay * 1000L, title, message, message, sound ? 1 : 0, vibrate ? 1 : 0, lights ? 1 : 0, bigIcon, "notify_icon_small", bgColor.r * 65536 + bgColor.g * 256 + bgColor.b, (int)executeMode);
     }
     #endif
 }
コード例 #3
0
    public static void SendNotification(int id, long delay, string title, string message, Color32 bgColor, bool sound = true, bool vibrate = true, bool lights = true, string bigIcon = "", NotificationExecuteMode executeMode = NotificationExecuteMode.Inexact)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
        if (pluginClass != null)
        {
            pluginClass.CallStatic("SetNotification", id, delay * 1000L, title, message, message, sound ? 1 : 0, vibrate ? 1 : 0, lights ? 1 : 0, bigIcon, "notify_icon_small", bgColor.r * 65536 + bgColor.g * 256 + bgColor.b, (int)executeMode, mainActivityClassName);
        }
#elif UNITY_IOS && !UNITY_EDITOR
    UnityEngine.iOS.LocalNotification iNoti = new UnityEngine.iOS.LocalNotification();
    iNotiMap.Add(id, iNoti);
    iNoti.fireDate = DateTime.Now.AddSeconds ((double) delay);
    iNoti.alertAction = title;
    iNoti.alertBody = message;
    iNoti.soundName = UnityEngine.iOS.LocalNotification.defaultSoundName;
    iNoti.hasAction = false;    
    UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(iNoti);
#endif
  }
コード例 #4
0
    public static void SendNotification(int id, long delay, string title, string message, Color32 bgColor, bool sound = true, bool vibrate = true, bool lights = true, string bigIcon = "", NotificationExecuteMode executeMode = NotificationExecuteMode.Inexact)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
        if (pluginClass != null)
        {
            pluginClass.CallStatic("SetNotification", id, delay * 1000L, title, message, message, sound ? 1 : 0, vibrate ? 1 : 0, lights ? 1 : 0, bigIcon, "notify_icon_small", bgColor.r * 65536 + bgColor.g * 256 + bgColor.b, (int)executeMode, mainActivityClassName);
        }
#endif
    }
コード例 #5
0
    /// <summary>
    /// Отправить Push-уведомление
    /// </summary>
    /// <param name="id"></param>
    /// <param name="delay">Задержка (мининум 5 секунд)</param>
    /// <param name="title">Заголовок</param>
    /// <param name="message">Сообщение</param>
    /// <param name="ticker">Сообщение при появлении в статус баре</param>
    /// <param name="bgColor">Цвет заднего фона в ARGB формате. Информация: "https://developer.android.com/reference/android/graphics/Color.html#BLACK"</param>
    /// <param name="sound">Включить звук уведомления?</param>
    /// <param name="vibrate">Включить вибрацию?</param>
    /// <param name="vibrateDelay">Задержка перед вибрацией</param>
    /// <param name="vibrateTime">Длительность вибрации</param>
    /// <param name="lights">Включить световое оповещение?</param>
    /// <param name="executeMode">Способ выполнения</param>
    public static void SendNotification(int id, long delay, string title, string message, string ticker, Color32 bgColor, bool lights = true, NotificationExecuteMode executeMode = NotificationExecuteMode.Inexact, bool sound = true, int soundIndex = 2, bool vibrate = true, long vibrateDelay = 1000L, long vibrateTime = 1000L)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
        if (pluginClass != null)
        {
            pluginClass.CallStatic("SetNotification", id, delay * 1000L, title, message, ticker, sound ? 1 : 0, soundIndex, vibrate ? 1 : 0, vibrateDelay, vibrateTime, lights ? 1 : 0, bgColor.r * 65536 + bgColor.g * 256 + bgColor.b, (int)executeMode, mainActivityClassName);
        }
#endif
    }
コード例 #6
0
 /// <summary>
 /// Отправить Push-уведомление
 /// </summary>
 /// <param name="id"></param>
 /// <param name="delay">Задержка (мининум 5 секунд)</param>
 /// <param name="title">Заголовок</param>
 /// <param name="message">Сообщение</param>
 /// <param name="ticker">Сообщение при появлении в статус баре</param>
 /// <param name="bgColor">Цвет заднего фона в ARGB формате. Информация: "https://developer.android.com/reference/android/graphics/Color.html#BLACK"</param>
 /// <param name="sound">Включить звук уведомления?</param>
 /// <param name="vibrate">Включить вибрацию?</param>
 /// <param name="lights">Включить световое оповещение?</param>
 /// <param name="executeMode">Способ выполнения</param>
 public static void SendNotification(int id, TimeSpan delay, string title, string message, string ticker, Color32 bgColor, bool lights = true, NotificationExecuteMode executeMode = NotificationExecuteMode.Inexact, bool sound = true, int soundIndex = 2)
 {
     SendNotification(id, (int)delay.TotalSeconds, title, message, ticker, bgColor, lights, executeMode, sound, soundIndex);
 }
コード例 #7
0
    public static void SendNotification(int id, long delay, string title, string message, string ticker, Color32 bgColor, bool lights = true, NotificationExecuteMode executeMode = 0, bool sound = true, int soundIndex = 2, bool vibrate = true, long vibrateDelay = 0x3e8L, long vibrateTime = 0x3e8L)
    {
        AndroidJavaClass class2 = new AndroidJavaClass("com.ahg.uanotify.UnityNotification");

        if (class2 != null)
        {
            object[] args = new object[] { id, delay * 0x3e8L, title, message, ticker, !sound ? 0 : 1, soundIndex, !vibrate ? 0 : 1, vibrateDelay, vibrateTime, !lights ? 0 : 1, ((bgColor.r * 0x10000) + (bgColor.g * 0x100)) + bgColor.b, (int)executeMode, "com.unity3d.player.UnityPlayerNativeActivity" };
            class2.CallStatic("SetNotification", args);
        }
    }
コード例 #8
0
 public static void SendNotification(int id, TimeSpan delay, string title, string message, string ticker, Color32 bgColor, bool lights = true, NotificationExecuteMode executeMode = 0, bool sound = true, int soundIndex = 2)
 {
     SendNotification(id, (long)((int)delay.TotalSeconds), title, message, ticker, bgColor, lights, executeMode, sound, soundIndex, true, 0x3e8L, 0x3e8L);
 }