Skip to content

Commit 98ef403

Browse files
committed
Update api
Align api with latest version of lib - 7.2.0, added more methods, fixed typedefs
1 parent 86b0ddd commit 98ef403

File tree

1 file changed

+74
-25
lines changed

1 file changed

+74
-25
lines changed

src/react/native/push_notification/PushNotification.hx

Lines changed: 74 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ extern class PushNotification {
55
static function configure(config:Config):Void;
66
static function localNotification(data:LocalNotification):Void;
77
static function localNotificationSchedule(data:ScheduledLocalNotification):Void;
8+
static function getDeliveredNotifications(cb:Array<DeliveredNotification>->Void):Void;
9+
static function removeDeliveredNotifications(arr:Array<Int>):Void;
810
}
911

1012
typedef Config = {
11-
?onRegister:String->Void,
13+
?onRegister:Token->Void,
1214
?onNotification:Notification->Void,
1315
?popInitialNotification:Bool,
1416
?requestPermissions:Bool,
@@ -23,11 +25,36 @@ typedef Config = {
2325
#end
2426
}
2527

28+
typedef Token = {
29+
final token:String;
30+
final os:TokenOS;
31+
}
32+
33+
enum abstract TokenOS(String) to String {
34+
var ios;
35+
var android;
36+
}
37+
2638
typedef Notification = {
2739
foreground:Bool,
2840
userInteraction:Bool,
2941
message:String,
30-
data:{},
42+
finish:FetchResult->Void,
43+
data:{}
44+
}
45+
46+
enum abstract FetchResult(String) to String {
47+
var NewData = 'backgroundFetchResultNewData';
48+
var NoData = 'backgroundFetchResultNoData';
49+
var ResultFailed = 'backgroundFetchResultFailed';
50+
}
51+
52+
typedef DeliveredNotification = {
53+
identifier:Int,
54+
title:String,
55+
body:{},
56+
?category:String,
57+
?userInfo:{},
3158
}
3259

3360
typedef ScheduledLocalNotification = {
@@ -37,31 +64,53 @@ typedef ScheduledLocalNotification = {
3764

3865
typedef LocalNotification = {
3966
#if android
40-
?id:String,
41-
?ticker:String,
42-
?autoCancel:Bool,
43-
?largeIcon:String,
44-
?smallIcon:String,
45-
?bigText:String,
46-
?subText:String,
47-
?color:String,
48-
?vibrate:Bool,
49-
?vibration:Int,
50-
?tag:String,
51-
?group:String,
52-
?ongoing:Bool,
53-
?repeatType:RepeatType,
54-
?actions:Action,
67+
channelId:String, // (required) channelId, if the channel doesn't exist, notification will not trigger.
68+
?ticker:String, // (optional)
69+
?showWhen:Bool, // (optional) default: true
70+
?autoCancel:Bool, // (optional) default: true
71+
?largeIcon:String, // (optional) default: "ic_launcher". Use "" for no large icon.
72+
?largeIconUrl:String, // (optional) default: undefined
73+
?smallIcon:String, // (optional) default: "ic_notification" with fallback for "ic_launcher". Use "" for default small icon.
74+
?bigText:String, // (optional) default: "message" prop
75+
?subText:String, // (optional) default: none
76+
?bigPictureUrl:String, // (optional) default: undefined
77+
?bigLargeIcon:String, // (optional) default: undefined
78+
?bigLargeIconUrl:String, // (optional) default: undefined
79+
?color:String, // (optional) default: system default
80+
?vibrate:Bool, // (optional) default: true
81+
vibration:Int, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
82+
?tag:String, // (optional) add tag to message
83+
?group:String, // (optional) add group to message
84+
?roupSummary:Bool, // (optional) set this notification to be the group summary for a group of notifications, default: false
85+
?ongoing:Bool, // (optional) set whether this is an "ongoing" notification
86+
?priority:String, // (optional) set notification priority, default: high
87+
?visibility:String, // (optional) set notification visibility, default: private
88+
?ignoreInForeground:Bool, // (optional) if true, the notification will not be visible when the app is in the foreground (useful for parity with how iOS notifications appear). should be used in combine with `com.dieam.reactnativepushnotification.notification_foreground` setting
89+
?shortcutId:String, // (optional) If this notification is duplicative of a Launcher shortcut, sets the id of the shortcut, in case the Launcher wants to hide the shortcut, default undefined
90+
?onlyAlertOnce:Bool, // (optional) alert will open only once with sound and notify, default: false
91+
92+
?when:Int, // (optional) Add a timestamp (Unix timestamp value in milliseconds) pertaining to the notification (usually the time the event occurred). For apps targeting Build.VERSION_CODES.N and above, this time is not shown anymore by default and must be opted into by using `showWhen`, default: null.
93+
?usesChronometer:Bool, // (optional) Show the `when` field as a stopwatch. Instead of presenting `when` as a timestamp, the notification will show an automatically updating display of the minutes and seconds since when. Useful when showing an elapsed time (like an ongoing phone call), default: false.
94+
?timeoutAfter:Int, // (optional) Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled, default: null
95+
96+
?messageId:String, // (optional) added as `message_id` to intent extras so opening push notification can find data stored by @react-native-firebase/messaging module.
97+
98+
actions:Action, // (Android only) See the doc for notification actions to know more
99+
?invokeApp:Bool, // (optional) This enable click on actions to bring back the application to foreground or stay in background, default: true
100+
55101
#else
56-
?alertAction:Dynamic,
57-
?category:Dynamic,
58-
?userInfo:{},
102+
?category:String, // (optional) default: empty string
103+
?subtitle:String, // (optional) smaller title below notification title
104+
59105
#end
60-
?title:String,
61-
message:String,
62-
?playSound:Bool,
63-
?soundName:String,
64-
?number:String,
106+
?id:Int, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
107+
?title:String, // (optional)
108+
message:String, // (required)
109+
?userInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)
110+
?playSound:Bool, // (optional) default: true
111+
?soundName:String, // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
112+
?number:Int, // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
113+
?repeatType:RepeatType // (optional) Repeating interval. Check 'Repeating Notifications' section for more info.
65114
}
66115

67116
@:enum

0 commit comments

Comments
 (0)