67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
|
|
namespace Thousandto.Code.Logic
|
|
{
|
|
public enum LocalNoticeType
|
|
{
|
|
Notice_1502 = 1502,
|
|
Notice_1932 = 1932,
|
|
}
|
|
|
|
public class LocalAndroidNotification
|
|
{
|
|
/// <summary>
|
|
/// Inexact uses `set` method
|
|
/// Exact uses `setExact` method
|
|
/// ExactAndAllowWhileIdle uses `setAndAllowWhileIdle` method
|
|
/// Documentation: https://developer.android.com/intl/ru/reference/android/app/AlarmManager.html
|
|
/// </summary>
|
|
|
|
|
|
#if UNITY_ANDROID
|
|
private static string fullClassName = "com.funcell.liushanmen.UnityNotificationManager";
|
|
|
|
private static AndroidJavaClass _pluginClass = null;
|
|
private static void callStatic(string funcName, params object[] args)
|
|
{
|
|
try
|
|
{
|
|
if (_pluginClass == null)
|
|
{
|
|
_pluginClass = new AndroidJavaClass(fullClassName);
|
|
}
|
|
|
|
if (_pluginClass != null)
|
|
{
|
|
_pluginClass.CallStatic(funcName, args);
|
|
}
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
UnityEngine.Debug.LogError("LocalAndroidNotification: jni error, not found function-> " + funcName);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
//SetRepeatingNotification(int id, int hour, int minute, int second, String title, String message,
|
|
// int sound, int vibrate, int lights, String appIcon, String activityName)
|
|
public static void SendRepeatingNotification(LocalNoticeType id, int hour, int minute, int second, string title, string message,
|
|
int sound = 1, int vbrate = 1, int lights = 1,
|
|
string appIcon = "app_icon", string activity = "com.funcell.liushanmen.UnityPlayerNativeActivity")
|
|
{
|
|
#if UNITY_ANDROID
|
|
callStatic("SetRepeatingNotification", (int)id, hour, minute, second, title, message, sound, vbrate, lights, appIcon, activity);
|
|
#endif
|
|
}
|
|
|
|
public static void CancelNotification(LocalNoticeType id)
|
|
{
|
|
#if UNITY_ANDROID
|
|
callStatic("CancelNotification", (int)id);
|
|
#endif
|
|
}
|
|
}
|
|
} |