-
Notifications
You must be signed in to change notification settings - Fork 0
/
notificationmanager.monkey
87 lines (65 loc) · 1.65 KB
/
notificationmanager.monkey
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Strict
#If TARGET<>"android" And TARGET<>"ios"
'#Error "The local notification module is only available on the android and ios targets"
#End
#If TARGET="android"
Import "native/android/notificationmanager.android.java"
#ElseIf TARGET="ios"
Import "native/ios/notificationmanager.ios.cpp"
#End
Class NotificationManager Extends NativeNotificationManager
Function GetInstance:NotificationManager()
If not instance
instance = New NotificationManager()
EndIf
Return instance
End
Method CancelScheduled:Void(id:Int)
NativeCancelScheduled(id)
End
Method CancelAll:Void()
NativeCancelAll()
End
Method GetExtra:String(key:String)
Return NativeGetExtra(key)
End
#if TARGET="ios"
Method SetBadgeNumber:Void(number:Int = -1)
NativeSetBadgeNumber(number)
End
#end
Private
'Global init:Bool = False
Global instance:NotificationManager
Method New()
'If not init
NativeInit()
' init = True
'EndIf
End
End
#If TARGET<>"android" And TARGET<>"ios"
Class NativeNotificationManager
Private
Method NativeInit:Void()
End
Method NativeGetExtra:String(key:String)
Return ""
End
Method NativeCancelAll:Void()
End
Method NativeCancelScheduled:Void(id:Int)
End
End
#else
Extern
Class NativeNotificationManager
Method NativeInit:Void()
Method NativeGetExtra:String(key:String)
Method NativeCancelAll:Void()
#if TARGET="ios"
Method NativeSetBadgeNumber:Void(number:Int)
#end
Method NativeCancelScheduled:Void(id:Int)
End
#end