2828添加事件监听方法。
2929
3030``` dart
31- JPush.addEventHandler(
31+ JPush jpush = new JPush();
32+ jpush.addEventHandler(
3233 // 接收通知回调方法。
3334 onReceiveNotification: (Map<String, dynamic> message) async {
3435 print("flutter onReceiveNotification: $message");
@@ -52,7 +53,8 @@ JPush.addEventHandler(
5253- 将缓存的事件下发到 dart 环境中。
5354
5455``` dart
55- JPush.setup(
56+ JPush jpush = new JPush();
57+ jpush.setup(
5658 appKey: "替换成你自己的 appKey",
5759 channel: "theChannel",
5860 production: false
@@ -64,79 +66,88 @@ JPush.setup(
6466获取 registrationId,这个 JPush 运行通过 registrationId 来进行推送.
6567
6668``` dart
67- JPush.getRegistrationID().then((rid) { });
69+ JPush jpush = new JPush();
70+ jpush.getRegistrationID().then((rid) { });
6871```
6972
7073#### stopPush
7174
7275停止推送功能,调用该方法将不会接收到通知。
7376
7477``` dart
75- JPush.stopPush();
78+ JPush jpush = new JPush();
79+ jpush.stopPush();
7680```
7781
7882#### resumePush
7983
8084调用 stopPush 后,可以通过 resumePush 方法恢复推送。
8185
8286``` dart
83- JPush.resumePush();
87+ JPush jpush = new JPush();
88+ jpush.resumePush();
8489```
8590
8691#### setAlias
8792
8893设置别名,极光后台可以通过别名来推送,一个 App 应用只有一个别名,一般用来存储用户 id。
8994
9095```
91- JPush.setAlias("your alias").then((map) { });
96+ JPush jpush = new JPush();
97+ jpush.setAlias("your alias").then((map) { });
9298```
9399
94100#### deleteAlias
95101
96102可以通过 deleteAlias 方法来删除已经设置的 alias。
97103
98104``` dart
99- JPush.deleteAlias().then((map) {})
105+ JPush jpush = new JPush();
106+ jpush.deleteAlias().then((map) {})
100107```
101108
102109#### addTags
103110
104111在原来的 Tags 列表上添加指定 tags。
105112
106113```
107- JPush.addTags(["tag1","tag2"]).then((map) {});
114+ JPush jpush = new JPush();
115+ jpush.addTags(["tag1","tag2"]).then((map) {});
108116```
109117
110118#### deleteTags
111119
112120在原来的 Tags 列表上删除指定 tags。
113121
114122```
115- JPush.deleteTags(["tag1","tag2"]).then((map) {});
123+ JPush jpush = new JPush();
124+ jpush.deleteTags(["tag1","tag2"]).then((map) {});
116125```
117126
118127#### setTags
119128
120129重置 tags。
121130
122- ```
123- JPush.setTags(["tag1","tag2"]).then((map) {});
131+ ``` dart
132+ JPush jpush = new JPush();
133+ jpush.setTags(["tag1","tag2"]).then((map) {});
124134```
125135
126136#### cleanTags
127137
128138清空所有 tags
129139
130140``` dart
131- JPush .setTags().then((map) {});
141+ jpush .setTags().then((map) {});
132142```
133143
134144#### getAllTags
135145
136146获取当前 tags 列表。
137147
138- ```
139- JPush.getAllTags().then((map) {});
148+ ``` dart
149+ JPush jpush = new JPush();
150+ jpush.getAllTags().then((map) {});
140151```
141152
142153#### sendLocalNotification
@@ -145,6 +156,7 @@ JPush.getAllTags().then((map) {});
145156
146157``` dart
147158// 延时 3 秒后触发本地通知。
159+ JPush jpush = new JPush();
148160var fireDate = DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch + 3000);
149161var localNotification = LocalNotification(
150162 id: 234,
@@ -156,15 +168,16 @@ var localNotification = LocalNotification(
156168 badge: 5, // 该参数只有在 iOS 有效
157169 extras: {"fa": "0"} // 设置 extras ,extras 需要是 Map<String, String>
158170 );
159- JPush .sendLocalNotification(localNotification).then((res) {});
171+ jpush .sendLocalNotification(localNotification).then((res) {});
160172```
161173
162174#### clearAllNotifications
163175
164176清楚通知栏上所有通知。
165177
166178``` dart
167- JPush.clearAllNotifications();
179+ JPush jpush = new JPush();
180+ jpush.clearAllNotifications();
168181```
169182
170183#### applyPushAuthority
@@ -174,7 +187,8 @@ JPush.clearAllNotifications();
174187** 注意: iOS10+ 可以通过该方法来设置推送是否前台展示,是否触发声音,是否设置应用角标 badge**
175188
176189``` dart
177- JPush.applyPushAuthority(new NotificationSettingsIOS(
190+ JPush jpush = new JPush();
191+ jpush.applyPushAuthority(new NotificationSettingsIOS(
178192 sound: true,
179193 alert: true,
180194 badge: true));
@@ -187,14 +201,16 @@ JPush.applyPushAuthority(new NotificationSettingsIOS(
187201设置应用 badge 值,该方法还会同步 JPush 服务器的的 badge 值,JPush 服务器的 badge 值用于推送 badge 自动 +1 时会用到。
188202
189203``` dart
190- JPush.setBadge(66).then((map) {});
204+ JPush jpush = new JPush();
205+ jpush.setBadge(66).then((map) {});
191206```
192207
193208### getLaunchAppNotification
194209
195210获取 iOS 点击推送启动应用的那条通知。
196211
197212``` dart
198- JPush.getLaunchAppNotification().then((map) {});
213+ JPush jpush = new JPush();
214+ jpush.getLaunchAppNotification().then((map) {});
199215```
200216
0 commit comments