capacitor-jpush-core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorJpushCore'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '14.0'
15
+ s.dependency 'Capacitor'
16
+ s.dependency 'JPush', '~> 4.8.0'
17
+ s.swift_version = '5.1'
18
+
19
+ end
package/Package.swift ADDED
@@ -0,0 +1,29 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "capacitor-jpush-core",
6
+ platforms: [.iOS(.v14)],
7
+ products: [
8
+ .library(
9
+ name: "capacitor-jpush-core",
10
+ targets: ["JPushPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "JPushPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm"),
21
+ ],
22
+ path: "ios/Sources/JPushPlugin"),
23
+
24
+ .testTarget(
25
+ name: "JPushPluginTests",
26
+ dependencies: ["JPushPlugin"],
27
+ path: "ios/Tests/JPushPluginTests"),
28
+ ]
29
+ )
package/README.md ADDED
@@ -0,0 +1,496 @@
1
+ # capacitor-jpush-core
2
+
3
+ 极光推送Capacitor插件,支持Android和iOS平台的一些简单功能。
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install capacitor-jpush-core
9
+ npx cap sync
10
+ ```
11
+
12
+ ## 平台支持
13
+
14
+ | 功能 | iOS | Android | 备注 |
15
+ |------|-----|---------|------|
16
+ | 设置别名 | ✅ | ✅ | |
17
+ | 删除别名 | ✅ | ✅ | |
18
+ | 获取注册ID | ✅ | ✅ | |
19
+ | 设置角标 | ✅ | ❌ | 未集成厂商通道 |
20
+ | 通知接收 | ✅ | ✅ | |
21
+ | 通知点击回调 | ✅ | ✅ | Android仅限App运行时 |
22
+ | 自定义消息 | ✅ | ✅ | |
23
+ | 权限检查 | ✅ | ✅ | |
24
+ | 权限请求 | ✅ | ✅ | |
25
+
26
+ ## Capacitor.config 配置
27
+
28
+ ```json
29
+ {
30
+ "plugins": {
31
+ "JPush": {
32
+ // 极光推送AppKey
33
+ "appKey": "your_app_key",
34
+ // 推送通道,默认值为default, 没统计需求随便填
35
+ "channel": "default",
36
+ // 是否为生产环境,默认值为false
37
+ "production": false,
38
+ // 进入App时是否自动清除角标,默认值为false
39
+ "activeClearBadge": false,
40
+ // 是否跟随App启动时自动注册极光推送,默认值为false
41
+ "iosAutoRegister": true
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ ## iOS 准备工作
48
+
49
+ ### xcode 配置
50
+ - 在 sign & capabilities 中点击 `+ capability` 按钮,搜索并添加 `Background Modes` 和 `Push Notifications` 选项。
51
+ - 在 `Background Modes` 中勾选 `Remote notifications` 子项。
52
+
53
+ ### AppDelegate 基础配置
54
+ 在主工程的`AppDelegate`以下代理方法中,添加发送通知的代码
55
+ ```swift
56
+ class AppDelegate: UIResponder, UIApplicationDelegate {
57
+
58
+ func applicationDidBecomeActive(_ application: UIApplication) {
59
+ // 从后台到前台,包括冷启动都会进入这个方法
60
+ NotificationCenter.default.post(name: UIApplication.didBecomeActiveNotification, object: nil)
61
+ }
62
+
63
+ func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
64
+ // 通知设备注册成功的消息
65
+ NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
66
+ }
67
+ func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
68
+ // 通知设备注册失败的消息
69
+ NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### 推送唤醒
75
+ - 当应用在后台收到远程推送时,会触发 `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` 方法。
76
+ 如果需要增加该消息处理,需要在 `AppDelegate` 中添加以下代码和通知扩展,插件就能把该推送传给web层的接收消息监听`JPushEventName.NotificationReceived`。
77
+ ```swift
78
+ class AppDelegate: UIResponder, UIApplicationDelegate {
79
+ func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
80
+
81
+ NotificationCenter.default.post(name: .didReceiveRemotePush, object: userInfo)
82
+ completionHandler(.newData)
83
+ }
84
+ }
85
+ // 注意: 包括这个事件的定义也要复制进去
86
+ extension NSNotification.Name {
87
+ static let didReceiveRemotePush = NSNotification.Name("CapacitorJPushCoreBackgroundPush")
88
+ }
89
+ ```
90
+ 注意:后端发的推送需要配置[推送唤醒](https://docs.jiguang.cn/jpush/console/push_manage/creat#高级设置)
91
+
92
+ ### 未运行时点击推送消息
93
+ 如果需要处理回调的话,Capacitor.config 配置文件需要设置`iosAutoRegister`为`true`。必须在启动时就注册极光推送,否则本次点击推送消息不会触发后续在应用中添加的监听。
94
+ ```json
95
+ {
96
+ "plugins": {
97
+ "JPush": {
98
+ "iosAutoRegister": true
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ ## Android 准备工作
105
+
106
+ 我们使用capacitor配置,但是这里JPush需要一些元数据的占位符。
107
+ 在 Android 项目的 app/build.gradle 文件中,找到 android.defaultConfig 或对应 productFlavor 块,添加以下 manifestPlaceholders 配置:
108
+ ```gradle
109
+ defaultConfig {
110
+ manifestPlaceholders = [
111
+ JPUSH_PKGNAME: applicationId,
112
+ JPUSH_APPKEY: "",
113
+ JPUSH_CHANNEL: "default"
114
+ ]
115
+ }
116
+ ```
117
+
118
+ ## API
119
+
120
+ <docgen-index>
121
+
122
+ * [`setupJPush()`](#setupjpush)
123
+ * [`getRegistrationID()`](#getregistrationid)
124
+ * [`setAlias(...)`](#setalias)
125
+ * [`deleteAlias(...)`](#deletealias)
126
+ * [`setTags(...)`](#settags)
127
+ * [`addTags(...)`](#addtags)
128
+ * [`deleteTags(...)`](#deletetags)
129
+ * [`cleanTags()`](#cleantags)
130
+ * [`checkPermissions()`](#checkpermissions)
131
+ * [`requestPermissions()`](#requestpermissions)
132
+ * [`setBadge(...)`](#setbadge)
133
+ * [`addListener(JPushEventName.NotificationReceived, ...)`](#addlistenerjpusheventnamenotificationreceived-)
134
+ * [`addListener(JPushEventName.NotificationOpened, ...)`](#addlistenerjpusheventnamenotificationopened-)
135
+ * [`addListener(JPushEventName.CustomMessageReceived, ...)`](#addlistenerjpusheventnamecustommessagereceived-)
136
+ * [`addListener(JPushEventName.RegistrationCompleted, ...)`](#addlistenerjpusheventnameregistrationcompleted-)
137
+ * [`addListener(JPushEventName.RegistrationFailed, ...)`](#addlistenerjpusheventnameregistrationfailed-)
138
+ * [Interfaces](#interfaces)
139
+ * [Type Aliases](#type-aliases)
140
+ * [Enums](#enums)
141
+
142
+ </docgen-index>
143
+
144
+ <docgen-api>
145
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
146
+
147
+ ### setupJPush()
148
+
149
+ ```typescript
150
+ setupJPush() => Promise<void>
151
+ ```
152
+
153
+ --------------------
154
+
155
+
156
+ ### getRegistrationID()
157
+
158
+ ```typescript
159
+ getRegistrationID() => Promise<RegistrationIDResult>
160
+ ```
161
+
162
+ **Returns:** <code>Promise&lt;<a href="#registrationidresult">RegistrationIDResult</a>&gt;</code>
163
+
164
+ --------------------
165
+
166
+
167
+ ### setAlias(...)
168
+
169
+ ```typescript
170
+ setAlias(options: AliasOptions) => Promise<void>
171
+ ```
172
+
173
+ | Param | Type |
174
+ | ------------- | ----------------------------------------------------- |
175
+ | **`options`** | <code><a href="#aliasoptions">AliasOptions</a></code> |
176
+
177
+ --------------------
178
+
179
+
180
+ ### deleteAlias(...)
181
+
182
+ ```typescript
183
+ deleteAlias(options?: DeleteAlias | undefined) => Promise<void>
184
+ ```
185
+
186
+ | Param | Type |
187
+ | ------------- | --------------------------------------------------- |
188
+ | **`options`** | <code><a href="#deletealias">DeleteAlias</a></code> |
189
+
190
+ --------------------
191
+
192
+
193
+ ### setTags(...)
194
+
195
+ ```typescript
196
+ setTags(options: SetTagsOptions) => Promise<void>
197
+ ```
198
+
199
+ | Param | Type |
200
+ | ------------- | --------------------------------------------------------- |
201
+ | **`options`** | <code><a href="#settagsoptions">SetTagsOptions</a></code> |
202
+
203
+ --------------------
204
+
205
+
206
+ ### addTags(...)
207
+
208
+ ```typescript
209
+ addTags(options: SetTagsOptions) => Promise<void>
210
+ ```
211
+
212
+ | Param | Type |
213
+ | ------------- | --------------------------------------------------------- |
214
+ | **`options`** | <code><a href="#settagsoptions">SetTagsOptions</a></code> |
215
+
216
+ --------------------
217
+
218
+
219
+ ### deleteTags(...)
220
+
221
+ ```typescript
222
+ deleteTags(options: SetTagsOptions) => Promise<void>
223
+ ```
224
+
225
+ | Param | Type |
226
+ | ------------- | --------------------------------------------------------- |
227
+ | **`options`** | <code><a href="#settagsoptions">SetTagsOptions</a></code> |
228
+
229
+ --------------------
230
+
231
+
232
+ ### cleanTags()
233
+
234
+ ```typescript
235
+ cleanTags() => Promise<void>
236
+ ```
237
+
238
+ --------------------
239
+
240
+
241
+ ### checkPermissions()
242
+
243
+ ```typescript
244
+ checkPermissions() => Promise<PermissionStatus>
245
+ ```
246
+
247
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
248
+
249
+ --------------------
250
+
251
+
252
+ ### requestPermissions()
253
+
254
+ ```typescript
255
+ requestPermissions() => Promise<PermissionStatus>
256
+ ```
257
+
258
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
259
+
260
+ --------------------
261
+
262
+
263
+ ### setBadge(...)
264
+
265
+ ```typescript
266
+ setBadge(options: SetBadgeOptions) => Promise<void>
267
+ ```
268
+
269
+ | Param | Type |
270
+ | ------------- | ----------------------------------------------------------- |
271
+ | **`options`** | <code><a href="#setbadgeoptions">SetBadgeOptions</a></code> |
272
+
273
+ --------------------
274
+
275
+
276
+ ### addListener(JPushEventName.NotificationReceived, ...)
277
+
278
+ ```typescript
279
+ addListener(eventName: JPushEventName.NotificationReceived, listener: (data: PushNotificationData) => void) => Promise<PluginListenerHandle>
280
+ ```
281
+
282
+ | Param | Type |
283
+ | --------------- | ---------------------------------------------------------------------------------------- |
284
+ | **`eventName`** | <code><a href="#jpusheventname">JPushEventName.NotificationReceived</a></code> |
285
+ | **`listener`** | <code>(data: <a href="#pushnotificationdata">PushNotificationData</a>) =&gt; void</code> |
286
+
287
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
288
+
289
+ --------------------
290
+
291
+
292
+ ### addListener(JPushEventName.NotificationOpened, ...)
293
+
294
+ ```typescript
295
+ addListener(eventName: JPushEventName.NotificationOpened, listener: (data: PushNotificationData) => void) => Promise<PluginListenerHandle>
296
+ ```
297
+
298
+ | Param | Type |
299
+ | --------------- | ---------------------------------------------------------------------------------------- |
300
+ | **`eventName`** | <code><a href="#jpusheventname">JPushEventName.NotificationOpened</a></code> |
301
+ | **`listener`** | <code>(data: <a href="#pushnotificationdata">PushNotificationData</a>) =&gt; void</code> |
302
+
303
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
304
+
305
+ --------------------
306
+
307
+
308
+ ### addListener(JPushEventName.CustomMessageReceived, ...)
309
+
310
+ ```typescript
311
+ addListener(eventName: JPushEventName.CustomMessageReceived, listener: (data: CustomMessageData) => void) => Promise<PluginListenerHandle>
312
+ ```
313
+
314
+ | Param | Type |
315
+ | --------------- | ---------------------------------------------------------------------------------- |
316
+ | **`eventName`** | <code><a href="#jpusheventname">JPushEventName.CustomMessageReceived</a></code> |
317
+ | **`listener`** | <code>(data: <a href="#custommessagedata">CustomMessageData</a>) =&gt; void</code> |
318
+
319
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
320
+
321
+ --------------------
322
+
323
+
324
+ ### addListener(JPushEventName.RegistrationCompleted, ...)
325
+
326
+ ```typescript
327
+ addListener(eventName: JPushEventName.RegistrationCompleted, listener: (data: RegistrationCompletedData) => void) => Promise<PluginListenerHandle>
328
+ ```
329
+
330
+ | Param | Type |
331
+ | --------------- | -------------------------------------------------------------------------------------------------- |
332
+ | **`eventName`** | <code><a href="#jpusheventname">JPushEventName.RegistrationCompleted</a></code> |
333
+ | **`listener`** | <code>(data: <a href="#registrationcompleteddata">RegistrationCompletedData</a>) =&gt; void</code> |
334
+
335
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
336
+
337
+ --------------------
338
+
339
+
340
+ ### addListener(JPushEventName.RegistrationFailed, ...)
341
+
342
+ ```typescript
343
+ addListener(eventName: JPushEventName.RegistrationFailed, listener: (data: RegistrationFailedData) => void) => Promise<PluginListenerHandle>
344
+ ```
345
+
346
+ | Param | Type |
347
+ | --------------- | -------------------------------------------------------------------------------------------- |
348
+ | **`eventName`** | <code><a href="#jpusheventname">JPushEventName.RegistrationFailed</a></code> |
349
+ | **`listener`** | <code>(data: <a href="#registrationfaileddata">RegistrationFailedData</a>) =&gt; void</code> |
350
+
351
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
352
+
353
+ --------------------
354
+
355
+
356
+ ### Interfaces
357
+
358
+
359
+ #### RegistrationIDResult
360
+
361
+ | Prop | Type |
362
+ | -------------------- | ------------------- |
363
+ | **`registrationID`** | <code>string</code> |
364
+
365
+
366
+ #### AliasOptions
367
+
368
+ | Prop | Type |
369
+ | ----------- | ------------------- |
370
+ | **`alias`** | <code>string</code> |
371
+ | **`seq`** | <code>number</code> |
372
+
373
+
374
+ #### DeleteAlias
375
+
376
+ | Prop | Type |
377
+ | --------- | ------------------- |
378
+ | **`seq`** | <code>number</code> |
379
+
380
+
381
+ #### SetTagsOptions
382
+
383
+ | Prop | Type |
384
+ | ---------- | --------------------- |
385
+ | **`tags`** | <code>string[]</code> |
386
+ | **`seq`** | <code>number</code> |
387
+
388
+
389
+ #### PermissionStatus
390
+
391
+ 权限状态接口
392
+
393
+ | Prop | Type | Description |
394
+ | ---------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
395
+ | **`permission`** | <code>'prompt' \| 'prompt-with-rationale' \| 'granted' \| 'denied'</code> | 权限状态 - prompt: 首次申请,询问 - prompt-with-rationale:每次都询问 - granted:已获取权限 - denied:权限已拒绝 |
396
+
397
+
398
+ #### SetBadgeOptions
399
+
400
+ | Prop | Type |
401
+ | ----------- | ------------------- |
402
+ | **`badge`** | <code>number</code> |
403
+
404
+
405
+ #### PluginListenerHandle
406
+
407
+ | Prop | Type |
408
+ | ------------ | ----------------------------------------- |
409
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
410
+
411
+
412
+ #### PushNotificationData
413
+
414
+ | Prop | Type |
415
+ | -------------------- | ------------------------------------------------------------ |
416
+ | **`title`** | <code>string</code> |
417
+ | **`body`** | <code>string</code> |
418
+ | **`subtitle`** | <code>string</code> |
419
+ | **`badge`** | <code>number</code> |
420
+ | **`sound`** | <code>string</code> |
421
+ | **`extras`** | <code><a href="#record">Record</a>&lt;string, any&gt;</code> |
422
+ | **`messageId`** | <code>string</code> |
423
+ | **`notificationId`** | <code>number</code> |
424
+ | **`type`** | <code>'notification' \| 'custom' \| 'silent'</code> |
425
+ | **`rawData`** | <code><a href="#record">Record</a>&lt;string, any&gt;</code> |
426
+
427
+
428
+ #### CustomMessageData
429
+
430
+ | Prop | Type |
431
+ | --------------- | ------------------------------------------------------------ |
432
+ | **`title`** | <code>string</code> |
433
+ | **`body`** | <code>string</code> |
434
+ | **`extras`** | <code><a href="#record">Record</a>&lt;string, any&gt;</code> |
435
+ | **`messageId`** | <code>string</code> |
436
+ | **`type`** | <code>'notification' \| 'custom' \| 'silent'</code> |
437
+
438
+
439
+ #### RegistrationCompletedData
440
+
441
+ | Prop | Type |
442
+ | -------------------- | ------------------- |
443
+ | **`registrationID`** | <code>string</code> |
444
+
445
+
446
+ #### RegistrationFailedData
447
+
448
+ | Prop | Type |
449
+ | ------------------ | ------------------- |
450
+ | **`errorCode`** | <code>number</code> |
451
+ | **`errorMessage`** | <code>string</code> |
452
+
453
+
454
+ ### Type Aliases
455
+
456
+
457
+ #### Record
458
+
459
+ Construct a type with a set of properties K of type T
460
+
461
+ <code>{
462
  [P in K]: T;
1
463
  }</code>
464
+
465
+
466
+ ### Enums
467
+
468
+
469
+ #### JPushEventName
470
+
471
+ | Members | Value | Description |
472
+ | --------------------------- | ------------------------------------ | ----------- |
473
+ | **`NotificationReceived`** | <code>'notificationReceived'</code> | 通知接收事件 |
474
+ | **`NotificationOpened`** | <code>'notificationOpened'</code> | 通知点击事件 |
475
+ | **`CustomMessageReceived`** | <code>'customMessageReceived'</code> | 自定义消息接收事件 |
476
+ | **`RegistrationCompleted`** | <code>'registrationCompleted'</code> | 注册完成事件 |
477
+ | **`RegistrationFailed`** | <code>'registrationFailed'</code> | 注册失败事件 |
478
+
479
+ </docgen-api>
480
+
481
+ ## 开发依赖
482
+
483
+ - Capacitor 7 配套设施
484
+ - Node.js 20+
485
+ - TypeScript: ^5.9.3
486
+
487
+ 各平台要求,参考[capacitor7文档](https://capacitorjs.com/docs/updating/7-0)
488
+
489
+ - iOS 14+
490
+ - xcode 16+
491
+ - swift 5.9+
492
+
493
+ - Android 6.0+
494
+ - android studio 2024.2.1+
495
+ - Java JDK 21
496
+ - gradle plugin to 8.7.2
497
+ - gradle wrapper to 8.11.1
498
+ - kotlin 1.9.25
@@ -0,0 +1,79 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
6
+ // 极光推送SDK版本,会自动带出相应版本的JCore;
7
+ jpushVersion = '5.9.0'
8
+ }
9
+
10
+ buildscript {
11
+ // 关键:在 buildscript 内部声明 kotlinVersion(供构建脚本依赖使用)
12
+ ext {
13
+ kotlinVersion = project.hasProperty('kotlin_version') ? rootProject.ext.kotlin_version : '1.9.25'
14
+ }
15
+
16
+ repositories {
17
+ maven {
18
+ url "https://maven.aliyun.com/repository/google"
19
+ }
20
+ google()
21
+ mavenCentral()
22
+ }
23
+ dependencies {
24
+ classpath 'com.android.tools.build:gradle:8.7.2'
25
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
26
+ }
27
+ }
28
+
29
+ apply plugin: 'com.android.library'
30
+ apply plugin: 'org.jetbrains.kotlin.android'
31
+
32
+ android {
33
+ namespace "com.capacitor.jpush.core"
34
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
35
+ defaultConfig {
36
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
37
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
38
+ versionCode 1
39
+ versionName "1.0"
40
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
41
+ }
42
+ buildTypes {
43
+ release {
44
+ minifyEnabled false
45
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
46
+ }
47
+ }
48
+ lintOptions {
49
+ abortOnError false
50
+ }
51
+ compileOptions {
52
+ sourceCompatibility JavaVersion.VERSION_21
53
+ targetCompatibility JavaVersion.VERSION_21
54
+ }
55
+ kotlinOptions {
56
+ jvmTarget = '21'
57
+ }
58
+ }
59
+
60
+ repositories {
61
+ maven {
62
+ url "https://maven.aliyun.com/repository/google"
63
+ }
64
+ google()
65
+ mavenCentral()
66
+ }
67
+
68
+ dependencies {
69
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
70
+ implementation project(':capacitor-android')
71
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
72
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}"
73
+ testImplementation "junit:junit:$junitVersion"
74
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
75
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
76
+
77
+ // 极光 5.0.0 版本开始可以自动拉取 JCore
78
+ implementation "cn.jiguang.sdk:jpush:$jpushVersion"
79
+ }
@@ -0,0 +1,60 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:tools="http://schemas.android.com/tools">
4
+ <!-- 极光推送所需权限 -->
5
+ <!-- Required Required 一些系统要求的权限,如访问网络等 -->
6
+ <uses-permission android:name="android.permission.INTERNET" />
7
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
8
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
9
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
10
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
11
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
12
+
13
+ <!-- Required 用于获取手机设备标识 -->
14
+ <uses-permission
15
+ android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
16
+ tools:ignore="ProtectedPermissions" />
17
+
18
+ <!-- Optional 推送功能 -->
19
+ <uses-permission android:name="android.permission.VIBRATE" />
20
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
21
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
22
+ <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
23
+
24
+ <!-- Android 13+ 推送通知权限 -->
25
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
26
+
27
+ <!-- 华为&荣耀的角标 -->
28
+ <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE " />
29
+ <uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" />
30
+ <!-- 小米 MIUI 6 及以上设备支持数字角标,小米系统自动处理数字角标展示功能,默认收到通知+1处理,打开 App 清零。 -->
31
+ <!-- vivo 设备仅支持走极光通道时可以显示角标。 -->
32
+ <uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" />
33
+
34
+ <application>
35
+
36
+ <!-- 推送接收器) -->
37
+ <receiver
38
+ android:name=".JPushReceiver"
39
+ android:enabled="true"
40
+ android:exported="false">
41
+ <intent-filter>
42
+ <!-- JPushMessageReceiver 只需要这个action -->
43
+ <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" />
44
+ <category android:name="${applicationId}" />
45
+ </intent-filter>
46
+ </receiver>
47
+
48
+ <!-- 自定义JPush Service,继承自JCommonService(可选,用于扩展功能) -->
49
+ <service
50
+ android:name=".JPushService"
51
+ android:enabled="true"
52
+ android:exported="false">
53
+ <intent-filter>
54
+ <action android:name="cn.jiguang.user.service.action" />
55
+ </intent-filter>
56
+ </service>
57
+
58
+ </application>
59
+
60
+ </manifest>