expo-notifications 0.15.1 → 0.15.4
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.
- package/CHANGELOG.md +24 -0
- package/README.md +2 -0
- package/android/build.gradle +7 -3
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/java/expo/modules/notifications/service/NotificationForwarderActivity.kt +33 -0
- package/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt +60 -22
- package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoHandlingDelegate.kt +59 -25
- package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoSchedulingDelegate.kt +21 -6
- package/android/src/main/java/expo/modules/notifications/tokens/PushTokenModule.java +18 -0
- package/build/PushTokenManager.types.d.ts +1 -0
- package/build/PushTokenManager.types.d.ts.map +1 -1
- package/build/PushTokenManager.types.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/unregisterForNotificationsAsync.d.ts +2 -0
- package/build/unregisterForNotificationsAsync.d.ts.map +1 -0
- package/build/unregisterForNotificationsAsync.js +9 -0
- package/build/unregisterForNotificationsAsync.js.map +1 -0
- package/ios/EXNotifications/PushToken/EXPushTokenModule.m +7 -0
- package/ios/EXNotifications.xcframework/ios-arm64/EXNotifications.framework/EXNotifications +0 -0
- package/ios/EXNotifications.xcframework/ios-arm64/EXNotifications.framework/Info.plist +0 -0
- package/ios/EXNotifications.xcframework/ios-arm64_x86_64-simulator/EXNotifications.framework/EXNotifications +0 -0
- package/ios/EXNotifications.xcframework/ios-arm64_x86_64-simulator/EXNotifications.framework/Info.plist +0 -0
- package/package.json +2 -2
- package/src/PushTokenManager.types.ts +1 -0
- package/src/index.ts +1 -0
- package/src/unregisterForNotificationsAsync.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,30 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.15.4 — 2022-06-27
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 0.15.3 — 2022-06-17
|
|
18
|
+
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- Fix app not bringing to foreground when clicking notification on Android 12+. ([#17686](https://github.com/expo/expo/pull/17686) by [@kudo](https://github.com/kudo))
|
|
22
|
+
- Fixed Android data-only FCM notifications (i.e. notifications without a title and message) appearing in the notification drawer ([#17707](https://github.com/expo/expo/pull/17707) by [@sausti](https://github.com/sausti))
|
|
23
|
+
- Add support for unregistering from push notifications on Android and iOS ([#17812](https://github.com/expo/expo/pull/17812) by [@sausti](https://github.com/sausti))
|
|
24
|
+
- Fix another Android 12+ trampoline issue from push notifications. ([#17871](https://github.com/expo/expo/pull/17871) by [@kudo](https://github.com/kudo))
|
|
25
|
+
- Fixed `useLastNotificationResponse` returns latest received notification but not the clicked notification on Android. ([#17974](https://github.com/expo/expo/pull/17974) by [@kudo](https://github.com/kudo))
|
|
26
|
+
|
|
27
|
+
## 0.15.2 — 2022-05-05
|
|
28
|
+
|
|
29
|
+
### 🐛 Bug fixes
|
|
30
|
+
|
|
31
|
+
- Fixed Android 12+ runtime crash caused by `PendingIntent` misconfiguration. ([#17333](https://github.com/expo/expo/pull/17333) by [@kudo](https://github.com/kudo))
|
|
32
|
+
|
|
33
|
+
### ⚠️ Notices
|
|
34
|
+
|
|
35
|
+
- Fixed exception on Android 12+ devices for missing `SCHEDULE_EXACT_ALARM` permission. If `scheduleNotificationAsync` needs a precise timer, the `SCHEDULE_EXACT_ALARM` should be explicitly added to **AndroidManifest.xml**. ([#17334](https://github.com/expo/expo/pull/17334) by [@kudo](https://github.com/kudo))
|
|
36
|
+
|
|
13
37
|
## 0.15.1 — 2022-04-27
|
|
14
38
|
|
|
15
39
|
### 💡 Others
|
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ In order to be able to receive push notifications on the device ensure that your
|
|
|
47
47
|
|
|
48
48
|
This module requires permission to subscribe to device boot. It's used to setup the scheduled notifications right after the device (re)starts. The `RECEIVE_BOOT_COMPLETED` permission is added automatically.
|
|
49
49
|
|
|
50
|
+
**Note:** Starting from Android 12 (API level 31), to schedule the notification that triggers at the exact time, you need to add `<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>` to **AndroidManifest.xml**. You can read more about the exact alarm permission [here](https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission).
|
|
51
|
+
|
|
50
52
|
<details><summary><strong>Expand to view how the notification icon and the default color can be customized in a plain React Native app</strong></summary> <p>
|
|
51
53
|
|
|
52
54
|
- **To customize the icon**:
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '0.15.
|
|
6
|
+
version = '0.15.4'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
76
|
versionCode 21
|
|
77
|
-
versionName '0.15.
|
|
77
|
+
versionName '0.15.4'
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
lintOptions {
|
|
@@ -92,7 +92,11 @@ dependencies {
|
|
|
92
92
|
|
|
93
93
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
94
94
|
|
|
95
|
-
api 'com.google.firebase:firebase-messaging:
|
|
95
|
+
api 'com.google.firebase:firebase-messaging:22.0.0'
|
|
96
96
|
|
|
97
97
|
api 'me.leolin:ShortcutBadger:1.1.22@aar'
|
|
98
|
+
|
|
99
|
+
if (project.findProject(':expo-modules-test-core')) {
|
|
100
|
+
testImplementation project(':expo-modules-test-core')
|
|
101
|
+
}
|
|
98
102
|
}
|
|
@@ -27,5 +27,14 @@
|
|
|
27
27
|
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
|
28
28
|
</intent-filter>
|
|
29
29
|
</receiver>
|
|
30
|
+
|
|
31
|
+
<activity android:name=".service.NotificationForwarderActivity"
|
|
32
|
+
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
|
33
|
+
android:exported="false"
|
|
34
|
+
android:excludeFromRecents="true"
|
|
35
|
+
android:noHistory="true"
|
|
36
|
+
android:launchMode="standard"
|
|
37
|
+
android:taskAffinity=""
|
|
38
|
+
/>
|
|
30
39
|
</application>
|
|
31
40
|
</manifest>
|
package/android/src/main/java/expo/modules/notifications/service/NotificationForwarderActivity.kt
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package expo.modules.notifications.service
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
import expo.modules.notifications.BuildConfig
|
|
7
|
+
import expo.modules.notifications.service.delegates.ExpoHandlingDelegate
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An internal Activity that passes given Intent extras from
|
|
11
|
+
* [NotificationsService.createNotificationResponseIntent]
|
|
12
|
+
* and send broadcasts to [NotificationsService].
|
|
13
|
+
*/
|
|
14
|
+
class NotificationForwarderActivity : Activity() {
|
|
15
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
16
|
+
super.onCreate(savedInstanceState)
|
|
17
|
+
val broadcastIntent =
|
|
18
|
+
NotificationsService.createNotificationResponseBroadcastIntent(applicationContext, intent.extras)
|
|
19
|
+
val notificationResponse = NotificationsService.getNotificationResponseFromBroadcastIntent(broadcastIntent)
|
|
20
|
+
ExpoHandlingDelegate.openAppToForeground(this, notificationResponse)
|
|
21
|
+
sendBroadcast(broadcastIntent)
|
|
22
|
+
finish()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun onNewIntent(intent: Intent?) {
|
|
26
|
+
super.onNewIntent(intent)
|
|
27
|
+
// This Activity is expected to launch with new task, supposedly
|
|
28
|
+
// there's no way for `onNewIntent` to be called.
|
|
29
|
+
if (BuildConfig.DEBUG) {
|
|
30
|
+
throw AssertionError()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -7,20 +7,10 @@ import android.content.Context
|
|
|
7
7
|
import android.content.Intent
|
|
8
8
|
import android.content.pm.ActivityInfo
|
|
9
9
|
import android.net.Uri
|
|
10
|
-
import android.os
|
|
11
|
-
import android.os.Parcel
|
|
12
|
-
import android.os.Parcelable
|
|
13
|
-
import android.os.ResultReceiver
|
|
10
|
+
import android.os.*
|
|
14
11
|
import android.util.Log
|
|
15
12
|
import androidx.core.app.RemoteInput
|
|
16
|
-
import expo.modules.notifications.notifications.model
|
|
17
|
-
import expo.modules.notifications.notifications.model.NotificationAction
|
|
18
|
-
import expo.modules.notifications.notifications.model.NotificationBehavior
|
|
19
|
-
import expo.modules.notifications.notifications.model.NotificationCategory
|
|
20
|
-
import expo.modules.notifications.notifications.model.NotificationRequest
|
|
21
|
-
import expo.modules.notifications.notifications.model.NotificationResponse
|
|
22
|
-
import expo.modules.notifications.notifications.model.TextInputNotificationAction
|
|
23
|
-
import expo.modules.notifications.notifications.model.TextInputNotificationResponse
|
|
13
|
+
import expo.modules.notifications.notifications.model.*
|
|
24
14
|
import expo.modules.notifications.service.delegates.ExpoCategoriesDelegate
|
|
25
15
|
import expo.modules.notifications.service.delegates.ExpoHandlingDelegate
|
|
26
16
|
import expo.modules.notifications.service.delegates.ExpoPresentationDelegate
|
|
@@ -424,11 +414,13 @@ open class NotificationsService : BroadcastReceiver() {
|
|
|
424
414
|
intent.putExtra(IDENTIFIER_KEY, identifier)
|
|
425
415
|
}
|
|
426
416
|
|
|
417
|
+
// We're defaulting to the behaviour prior API 31 (mutable) even though Android recommends immutability
|
|
418
|
+
val mutableFlag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_MUTABLE else 0
|
|
427
419
|
return PendingIntent.getBroadcast(
|
|
428
420
|
context,
|
|
429
421
|
intent.component?.className?.hashCode() ?: NotificationsService::class.java.hashCode(),
|
|
430
422
|
intent,
|
|
431
|
-
PendingIntent.FLAG_UPDATE_CURRENT
|
|
423
|
+
PendingIntent.FLAG_UPDATE_CURRENT or mutableFlag
|
|
432
424
|
)
|
|
433
425
|
}
|
|
434
426
|
|
|
@@ -458,15 +450,67 @@ open class NotificationsService : BroadcastReceiver() {
|
|
|
458
450
|
intent.putExtra(NOTIFICATION_ACTION_KEY, action as Parcelable)
|
|
459
451
|
}
|
|
460
452
|
|
|
453
|
+
// Starting from Android 12,
|
|
454
|
+
// [notification trampolines](https://developer.android.com/about/versions/12/behavior-changes-12#identify-notification-trampolines)
|
|
455
|
+
// are not allowed. If the notification wants to open foreground app,
|
|
456
|
+
// we should use the dedicated Activity pendingIntent.
|
|
457
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && action.opensAppToForeground()) {
|
|
458
|
+
val notificationResponse = getNotificationResponseFromBroadcastIntent(intent)
|
|
459
|
+
return ExpoHandlingDelegate.createPendingIntentForOpeningApp(context, intent, notificationResponse)
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// We're defaulting to the behaviour prior API 31 (mutable) even though Android recommends immutability
|
|
463
|
+
val mutableFlag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_MUTABLE else 0
|
|
461
464
|
return PendingIntent.getBroadcast(
|
|
462
465
|
context,
|
|
463
466
|
intent.component?.className?.hashCode() ?: NotificationsService::class.java.hashCode(),
|
|
464
467
|
intent,
|
|
465
|
-
PendingIntent.FLAG_UPDATE_CURRENT
|
|
468
|
+
PendingIntent.FLAG_UPDATE_CURRENT or mutableFlag
|
|
466
469
|
)
|
|
467
470
|
}
|
|
468
471
|
|
|
469
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Recreate an Intent from [createNotificationResponseIntent] extras
|
|
474
|
+
* for [NotificationForwarderActivity] to send broadcasts
|
|
475
|
+
*/
|
|
476
|
+
fun createNotificationResponseBroadcastIntent(context: Context, extras: Bundle?): Intent {
|
|
477
|
+
val notification = extras?.getParcelable<Notification>(NOTIFICATION_KEY)
|
|
478
|
+
val action = extras?.getParcelable<NotificationAction>(NOTIFICATION_ACTION_KEY)
|
|
479
|
+
if (notification == null || action == null) {
|
|
480
|
+
throw IllegalArgumentException("notification and action should not be null")
|
|
481
|
+
}
|
|
482
|
+
val backgroundAction = NotificationAction(action.identifier, action.title, false)
|
|
483
|
+
val intent = Intent(
|
|
484
|
+
NOTIFICATION_EVENT_ACTION,
|
|
485
|
+
getUriBuilder()
|
|
486
|
+
.appendPath(notification.notificationRequest.identifier)
|
|
487
|
+
.appendPath("actions")
|
|
488
|
+
.appendPath(backgroundAction.identifier)
|
|
489
|
+
.build()
|
|
490
|
+
).also { intent ->
|
|
491
|
+
findDesignatedBroadcastReceiver(context, intent)?.let {
|
|
492
|
+
intent.component = ComponentName(it.packageName, it.name)
|
|
493
|
+
}
|
|
494
|
+
intent.putExtra(EVENT_TYPE_KEY, RECEIVE_RESPONSE_TYPE)
|
|
495
|
+
intent.putExtra(NOTIFICATION_KEY, notification)
|
|
496
|
+
intent.putExtra(NOTIFICATION_ACTION_KEY, backgroundAction as Parcelable)
|
|
497
|
+
}
|
|
498
|
+
return intent
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
fun getNotificationResponseFromBroadcastIntent(intent: Intent): NotificationResponse {
|
|
502
|
+
val notification = intent.getParcelableExtra<Notification>(NOTIFICATION_KEY) ?: throw IllegalArgumentException("$NOTIFICATION_KEY not found in the intent extras.")
|
|
503
|
+
val action = intent.getParcelableExtra<NotificationAction>(NOTIFICATION_ACTION_KEY) ?: throw IllegalArgumentException("$NOTIFICATION_ACTION_KEY not found in the intent extras.")
|
|
504
|
+
val response = if (action is TextInputNotificationAction) {
|
|
505
|
+
val userText = action.placeholder ?: RemoteInput.getResultsFromIntent(intent).getString(USER_TEXT_RESPONSE_KEY)
|
|
506
|
+
TextInputNotificationResponse(action, notification, userText)
|
|
507
|
+
} else {
|
|
508
|
+
NotificationResponse(action, notification)
|
|
509
|
+
}
|
|
510
|
+
return response
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
fun getNotificationResponseFromOpenIntent(intent: Intent): NotificationResponse? {
|
|
470
514
|
intent.getByteArrayExtra(NOTIFICATION_RESPONSE_KEY)?.let { return unmarshalObject(NotificationResponse.CREATOR, it) }
|
|
471
515
|
intent.getByteArrayExtra(TEXT_INPUT_NOTIFICATION_RESPONSE_KEY)?.let { return unmarshalObject(TextInputNotificationResponse.CREATOR, it) }
|
|
472
516
|
return null
|
|
@@ -646,13 +690,7 @@ open class NotificationsService : BroadcastReceiver() {
|
|
|
646
690
|
)
|
|
647
691
|
|
|
648
692
|
open fun onReceiveNotificationResponse(context: Context, intent: Intent) {
|
|
649
|
-
val
|
|
650
|
-
val action = intent.getParcelableExtra<NotificationAction>(NOTIFICATION_ACTION_KEY)!!
|
|
651
|
-
val response = if (action is TextInputNotificationAction) {
|
|
652
|
-
TextInputNotificationResponse(action, notification, RemoteInput.getResultsFromIntent(intent).getString(USER_TEXT_RESPONSE_KEY))
|
|
653
|
-
} else {
|
|
654
|
-
NotificationResponse(action, notification)
|
|
655
|
-
}
|
|
693
|
+
val response = getNotificationResponseFromBroadcastIntent(intent)
|
|
656
694
|
getHandlingDelegate(context).handleNotificationResponse(response)
|
|
657
695
|
}
|
|
658
696
|
|
package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoHandlingDelegate.kt
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
package expo.modules.notifications.service.delegates
|
|
2
2
|
|
|
3
|
+
import android.app.PendingIntent
|
|
3
4
|
import android.content.Context
|
|
4
5
|
import android.content.Intent
|
|
6
|
+
import android.os.Build
|
|
5
7
|
import android.util.Log
|
|
6
8
|
import androidx.lifecycle.Lifecycle
|
|
7
9
|
import androidx.lifecycle.ProcessLifecycleOwner
|
|
8
10
|
import expo.modules.notifications.notifications.NotificationManager
|
|
9
11
|
import expo.modules.notifications.notifications.model.Notification
|
|
10
12
|
import expo.modules.notifications.notifications.model.NotificationResponse
|
|
13
|
+
import expo.modules.notifications.service.NotificationForwarderActivity
|
|
11
14
|
import expo.modules.notifications.service.NotificationsService
|
|
12
15
|
import expo.modules.notifications.service.interfaces.HandlingDelegate
|
|
13
16
|
import java.lang.ref.WeakReference
|
|
@@ -50,6 +53,52 @@ class ExpoHandlingDelegate(protected val context: Context) : HandlingDelegate {
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Create a PendingIntent to open app in foreground.
|
|
59
|
+
* We actually start two Activities
|
|
60
|
+
* - the foreground main Activity
|
|
61
|
+
* - the background [NotificationForwarderActivity] Activity that send notification clicked events through broadcast
|
|
62
|
+
*/
|
|
63
|
+
fun createPendingIntentForOpeningApp(context: Context, broadcastIntent: Intent, notificationResponse: NotificationResponse): PendingIntent {
|
|
64
|
+
var intentFlags = PendingIntent.FLAG_UPDATE_CURRENT
|
|
65
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
66
|
+
// The intent may include `RemoteInput` from `TextInputNotificationAction`.
|
|
67
|
+
// For intent with RemoteInput, it should be mutable.
|
|
68
|
+
intentFlags = intentFlags or PendingIntent.FLAG_MUTABLE
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
val backgroundActivityIntent = Intent(context, NotificationForwarderActivity::class.java)
|
|
72
|
+
backgroundActivityIntent.data = broadcastIntent.data
|
|
73
|
+
backgroundActivityIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
|
|
74
|
+
backgroundActivityIntent.putExtras(broadcastIntent)
|
|
75
|
+
val requestCode = broadcastIntent.component?.className?.hashCode() ?: NotificationsService::class.java.hashCode()
|
|
76
|
+
return PendingIntent.getActivity(context, requestCode, backgroundActivityIntent, intentFlags)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fun openAppToForeground(context: Context, notificationResponse: NotificationResponse) {
|
|
80
|
+
(getNotificationActionLauncher(context) ?: getMainActivityLauncher(context))?.let { intent ->
|
|
81
|
+
NotificationsService.setNotificationResponseToIntent(intent, notificationResponse)
|
|
82
|
+
context.startActivity(intent)
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Log.w("expo-notifications", "No launch intent found for application. Interacting with the notification won't open the app. The implementation uses `getLaunchIntentForPackage` to find appropriate activity.")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private fun getNotificationActionLauncher(context: Context): Intent? {
|
|
90
|
+
Intent(OPEN_APP_INTENT_ACTION).also { intent ->
|
|
91
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
92
|
+
intent.setPackage(context.applicationContext.packageName)
|
|
93
|
+
context.packageManager.resolveActivity(intent, 0)?.let {
|
|
94
|
+
return intent
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private fun getMainActivityLauncher(context: Context) =
|
|
101
|
+
context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
53
102
|
}
|
|
54
103
|
|
|
55
104
|
fun isAppInForeground() = ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)
|
|
@@ -61,11 +110,20 @@ class ExpoHandlingDelegate(protected val context: Context) : HandlingDelegate {
|
|
|
61
110
|
getListeners().forEach {
|
|
62
111
|
it.onNotificationReceived(notification)
|
|
63
112
|
}
|
|
64
|
-
} else {
|
|
113
|
+
} else if (notification.shouldPresent()) {
|
|
65
114
|
NotificationsService.present(context, notification)
|
|
66
115
|
}
|
|
67
116
|
}
|
|
68
117
|
|
|
118
|
+
/**
|
|
119
|
+
* If the app is backgrounded, a notification is only presented if
|
|
120
|
+
* the title and or text is present. If both are null or empty, this is a "data-only" or "silent"
|
|
121
|
+
* notification that should not be presented to the user.
|
|
122
|
+
*/
|
|
123
|
+
private fun Notification.shouldPresent(): Boolean {
|
|
124
|
+
return !(notificationRequest.content.title.isNullOrEmpty() && notificationRequest.content.text.isNullOrEmpty())
|
|
125
|
+
}
|
|
126
|
+
|
|
69
127
|
override fun handleNotificationResponse(notificationResponse: NotificationResponse) {
|
|
70
128
|
if (notificationResponse.action.opensAppToForeground()) {
|
|
71
129
|
openAppToForeground(context, notificationResponse)
|
|
@@ -80,30 +138,6 @@ class ExpoHandlingDelegate(protected val context: Context) : HandlingDelegate {
|
|
|
80
138
|
}
|
|
81
139
|
}
|
|
82
140
|
|
|
83
|
-
protected fun openAppToForeground(context: Context, notificationResponse: NotificationResponse) {
|
|
84
|
-
(getNotificationActionLauncher(context) ?: getMainActivityLauncher(context))?.let { intent ->
|
|
85
|
-
NotificationsService.setNotificationResponseToIntent(intent, notificationResponse)
|
|
86
|
-
context.startActivity(intent)
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
Log.w("expo-notifications", "No launch intent found for application. Interacting with the notification won't open the app. The implementation uses `getLaunchIntentForPackage` to find appropriate activity.")
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private fun getNotificationActionLauncher(context: Context): Intent? {
|
|
94
|
-
Intent(OPEN_APP_INTENT_ACTION).also { intent ->
|
|
95
|
-
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
96
|
-
intent.setPackage(context.applicationContext.packageName)
|
|
97
|
-
context.packageManager.resolveActivity(intent, 0)?.let {
|
|
98
|
-
return intent
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return null
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private fun getMainActivityLauncher(context: Context) =
|
|
105
|
-
context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
106
|
-
|
|
107
141
|
override fun handleNotificationsDropped() {
|
|
108
142
|
getListeners().forEach {
|
|
109
143
|
it.onNotificationsDropped()
|
package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoSchedulingDelegate.kt
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package expo.modules.notifications.service.delegates
|
|
2
2
|
|
|
3
3
|
import android.app.AlarmManager
|
|
4
|
+
import android.app.PendingIntent
|
|
4
5
|
import android.content.Context
|
|
6
|
+
import android.os.Build
|
|
5
7
|
import android.util.Log
|
|
6
8
|
import androidx.core.app.AlarmManagerCompat
|
|
7
9
|
import expo.modules.notifications.notifications.interfaces.SchedulableNotificationTrigger
|
|
@@ -57,12 +59,7 @@ class ExpoSchedulingDelegate(protected val context: Context) : SchedulingDelegat
|
|
|
57
59
|
NotificationsService.removeScheduledNotification(context, request.identifier)
|
|
58
60
|
} else {
|
|
59
61
|
store.saveNotificationRequest(request)
|
|
60
|
-
|
|
61
|
-
alarmManager,
|
|
62
|
-
AlarmManager.RTC_WAKEUP,
|
|
63
|
-
nextTriggerDate.time,
|
|
64
|
-
NotificationsService.createNotificationTrigger(context, request.identifier)
|
|
65
|
-
)
|
|
62
|
+
setupAlarm(nextTriggerDate.time, NotificationsService.createNotificationTrigger(context, request.identifier))
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
}
|
|
@@ -99,4 +96,22 @@ class ExpoSchedulingDelegate(protected val context: Context) : SchedulingDelegat
|
|
|
99
96
|
alarmManager.cancel(NotificationsService.createNotificationTrigger(context, it))
|
|
100
97
|
}
|
|
101
98
|
}
|
|
99
|
+
|
|
100
|
+
private fun setupAlarm(triggerAtMillis: Long, operation: PendingIntent) {
|
|
101
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || alarmManager.canScheduleExactAlarms()) {
|
|
102
|
+
AlarmManagerCompat.setExactAndAllowWhileIdle(
|
|
103
|
+
alarmManager,
|
|
104
|
+
AlarmManager.RTC_WAKEUP,
|
|
105
|
+
triggerAtMillis,
|
|
106
|
+
operation
|
|
107
|
+
)
|
|
108
|
+
} else {
|
|
109
|
+
AlarmManagerCompat.setAndAllowWhileIdle(
|
|
110
|
+
alarmManager,
|
|
111
|
+
AlarmManager.RTC_WAKEUP,
|
|
112
|
+
triggerAtMillis,
|
|
113
|
+
operation
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
102
117
|
}
|
|
@@ -24,6 +24,7 @@ public class PushTokenModule extends ExportedModule implements PushTokenListener
|
|
|
24
24
|
private final static String NEW_TOKEN_EVENT_TOKEN_KEY = "devicePushToken";
|
|
25
25
|
|
|
26
26
|
private final static String REGISTRATION_FAIL_CODE = "E_REGISTRATION_FAILED";
|
|
27
|
+
private final static String UNREGISTER_FOR_NOTIFICATIONS_FAIL_CODE = "E_UNREGISTER_FOR_NOTIFICATIONS_FAILED";
|
|
27
28
|
|
|
28
29
|
private PushTokenManager mPushTokenManager;
|
|
29
30
|
private EventEmitter mEventEmitter;
|
|
@@ -81,6 +82,23 @@ public class PushTokenModule extends ExportedModule implements PushTokenListener
|
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
@ExpoMethod
|
|
86
|
+
public void unregisterForNotificationsAsync(final Promise promise) {
|
|
87
|
+
FirebaseMessaging.getInstance().deleteToken()
|
|
88
|
+
.addOnCompleteListener(task -> {
|
|
89
|
+
if (!task.isSuccessful()) {
|
|
90
|
+
if (task.getException() == null) {
|
|
91
|
+
promise.reject(UNREGISTER_FOR_NOTIFICATIONS_FAIL_CODE, "Unregistering for notifications failed.");
|
|
92
|
+
} else {
|
|
93
|
+
promise.reject(UNREGISTER_FOR_NOTIFICATIONS_FAIL_CODE, "Unregistering for notifications failed: " + task.getException().getMessage(), task.getException());
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
promise.resolve(null);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
/**
|
|
85
103
|
* Callback called when {@link PushTokenManager} gets notified of a new token.
|
|
86
104
|
* Emits a {@link PushTokenModule#NEW_TOKEN_EVENT_NAME} event.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ProxyNativeModule } from 'expo-modules-core';
|
|
2
2
|
export interface PushTokenManagerModule extends ProxyNativeModule {
|
|
3
3
|
getDevicePushTokenAsync?: () => Promise<string>;
|
|
4
|
+
unregisterForNotificationsAsync?: () => Promise<void>;
|
|
4
5
|
}
|
|
5
6
|
//# sourceMappingURL=PushTokenManager.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushTokenManager.types.d.ts","sourceRoot":"","sources":["../src/PushTokenManager.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,uBAAuB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"PushTokenManager.types.d.ts","sourceRoot":"","sources":["../src/PushTokenManager.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,uBAAuB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,+BAA+B,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushTokenManager.types.js","sourceRoot":"","sources":["../src/PushTokenManager.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from 'expo-modules-core';\n\nexport interface PushTokenManagerModule extends ProxyNativeModule {\n getDevicePushTokenAsync?: () => Promise<string>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PushTokenManager.types.js","sourceRoot":"","sources":["../src/PushTokenManager.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from 'expo-modules-core';\n\nexport interface PushTokenManagerModule extends ProxyNativeModule {\n getDevicePushTokenAsync?: () => Promise<string>;\n unregisterForNotificationsAsync?: () => Promise<void>;\n}\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';
|
|
2
|
+
export { default as unregisterForNotificationsAsync } from './unregisterForNotificationsAsync';
|
|
2
3
|
export { default as getExpoPushTokenAsync } from './getExpoPushTokenAsync';
|
|
3
4
|
export { default as getPresentedNotificationsAsync } from './getPresentedNotificationsAsync';
|
|
4
5
|
export { default as presentNotificationAsync } from './presentNotificationAsync';
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,OAAO,I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AgB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';
|
|
2
|
+
export { default as unregisterForNotificationsAsync } from './unregisterForNotificationsAsync';
|
|
2
3
|
export { default as getExpoPushTokenAsync } from './getExpoPushTokenAsync';
|
|
3
4
|
export { default as getPresentedNotificationsAsync } from './getPresentedNotificationsAsync';
|
|
4
5
|
export { default as presentNotificationAsync } from './presentNotificationAsync';
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,OAAO,IAAI,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,OAAO,I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,gBAAgB,CAAC","sourcesContent":["export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';\nexport { default as getExpoPushTokenAsync } from './getExpoPushTokenAsync';\nexport { default as getPresentedNotificationsAsync } from './getPresentedNotificationsAsync';\nexport { default as presentNotificationAsync } from './presentNotificationAsync';\nexport { default as dismissNotificationAsync } from './dismissNotificationAsync';\nexport { default as dismissAllNotificationsAsync } from './dismissAllNotificationsAsync';\nexport { default as getNotificationChannelsAsync } from './getNotificationChannelsAsync';\nexport { default as getNotificationChannelAsync } from './getNotificationChannelAsync';\nexport { default as setNotificationChannelAsync } from './setNotificationChannelAsync';\nexport { default as deleteNotificationChannelAsync } from './deleteNotificationChannelAsync';\nexport { default as getNotificationChannelGroupsAsync } from './getNotificationChannelGroupsAsync';\nexport { default as getNotificationChannelGroupAsync } from './getNotificationChannelGroupAsync';\nexport { default as setNotificationChannelGroupAsync } from './setNotificationChannelGroupAsync';\nexport { default as deleteNotificationChannelGroupAsync } from './deleteNotificationChannelGroupAsync';\nexport { default as getBadgeCountAsync } from './getBadgeCountAsync';\nexport { default as setBadgeCountAsync } from './setBadgeCountAsync';\nexport { default as getAllScheduledNotificationsAsync } from './getAllScheduledNotificationsAsync';\nexport { default as scheduleNotificationAsync } from './scheduleNotificationAsync';\nexport { default as cancelScheduledNotificationAsync } from './cancelScheduledNotificationAsync';\nexport { default as cancelAllScheduledNotificationsAsync } from './cancelAllScheduledNotificationsAsync';\nexport { default as getNotificationCategoriesAsync } from './getNotificationCategoriesAsync';\nexport { default as setNotificationCategoryAsync } from './setNotificationCategoryAsync';\nexport { default as deleteNotificationCategoryAsync } from './deleteNotificationCategoryAsync';\nexport { default as getNextTriggerDateAsync } from './getNextTriggerDateAsync';\nexport { default as useLastNotificationResponse } from './useLastNotificationResponse';\nexport { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';\nexport { default as registerTaskAsync } from './registerTaskAsync';\nexport { default as unregisterTaskAsync } from './unregisterTaskAsync';\nexport * from './TokenEmitter';\nexport * from './NotificationsEmitter';\nexport * from './NotificationsHandler';\nexport * from './NotificationPermissions';\nexport * from './NotificationChannelGroupManager.types';\nexport * from './NotificationChannelManager.types';\nexport * from './NotificationPermissions.types';\nexport * from './Notifications.types';\nexport * from './Tokens.types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,OAAO,IAAI,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AACvG,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AACzG,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,qCAAqC,EAAE,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC","sourcesContent":["export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';\nexport { default as unregisterForNotificationsAsync } from './unregisterForNotificationsAsync';\nexport { default as getExpoPushTokenAsync } from './getExpoPushTokenAsync';\nexport { default as getPresentedNotificationsAsync } from './getPresentedNotificationsAsync';\nexport { default as presentNotificationAsync } from './presentNotificationAsync';\nexport { default as dismissNotificationAsync } from './dismissNotificationAsync';\nexport { default as dismissAllNotificationsAsync } from './dismissAllNotificationsAsync';\nexport { default as getNotificationChannelsAsync } from './getNotificationChannelsAsync';\nexport { default as getNotificationChannelAsync } from './getNotificationChannelAsync';\nexport { default as setNotificationChannelAsync } from './setNotificationChannelAsync';\nexport { default as deleteNotificationChannelAsync } from './deleteNotificationChannelAsync';\nexport { default as getNotificationChannelGroupsAsync } from './getNotificationChannelGroupsAsync';\nexport { default as getNotificationChannelGroupAsync } from './getNotificationChannelGroupAsync';\nexport { default as setNotificationChannelGroupAsync } from './setNotificationChannelGroupAsync';\nexport { default as deleteNotificationChannelGroupAsync } from './deleteNotificationChannelGroupAsync';\nexport { default as getBadgeCountAsync } from './getBadgeCountAsync';\nexport { default as setBadgeCountAsync } from './setBadgeCountAsync';\nexport { default as getAllScheduledNotificationsAsync } from './getAllScheduledNotificationsAsync';\nexport { default as scheduleNotificationAsync } from './scheduleNotificationAsync';\nexport { default as cancelScheduledNotificationAsync } from './cancelScheduledNotificationAsync';\nexport { default as cancelAllScheduledNotificationsAsync } from './cancelAllScheduledNotificationsAsync';\nexport { default as getNotificationCategoriesAsync } from './getNotificationCategoriesAsync';\nexport { default as setNotificationCategoryAsync } from './setNotificationCategoryAsync';\nexport { default as deleteNotificationCategoryAsync } from './deleteNotificationCategoryAsync';\nexport { default as getNextTriggerDateAsync } from './getNextTriggerDateAsync';\nexport { default as useLastNotificationResponse } from './useLastNotificationResponse';\nexport { setAutoServerRegistrationEnabledAsync } from './DevicePushTokenAutoRegistration.fx';\nexport { default as registerTaskAsync } from './registerTaskAsync';\nexport { default as unregisterTaskAsync } from './unregisterTaskAsync';\nexport * from './TokenEmitter';\nexport * from './NotificationsEmitter';\nexport * from './NotificationsHandler';\nexport * from './NotificationPermissions';\nexport * from './NotificationChannelGroupManager.types';\nexport * from './NotificationChannelManager.types';\nexport * from './NotificationPermissions.types';\nexport * from './Notifications.types';\nexport * from './Tokens.types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unregisterForNotificationsAsync.d.ts","sourceRoot":"","sources":["../src/unregisterForNotificationsAsync.ts"],"names":[],"mappings":"AAIA,wBAA8B,+BAA+B,IAAI,OAAO,CAAC,IAAI,CAAC,CAK7E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
2
|
+
import PushTokenManager from './PushTokenManager';
|
|
3
|
+
export default async function unregisterForNotificationsAsync() {
|
|
4
|
+
if (!PushTokenManager.unregisterForNotificationsAsync) {
|
|
5
|
+
throw new UnavailabilityError('ExpoNotifications', 'unregisterForNotificationsAsync');
|
|
6
|
+
}
|
|
7
|
+
return PushTokenManager.unregisterForNotificationsAsync();
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=unregisterForNotificationsAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unregisterForNotificationsAsync.js","sourceRoot":"","sources":["../src/unregisterForNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,+BAA+B;IAC3D,IAAI,CAAC,gBAAgB,CAAC,+BAA+B,EAAE;QACrD,MAAM,IAAI,mBAAmB,CAAC,mBAAmB,EAAE,iCAAiC,CAAC,CAAC;KACvF;IACD,OAAO,gBAAgB,CAAC,+BAA+B,EAAE,CAAC;AAC5D,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport PushTokenManager from './PushTokenManager';\n\nexport default async function unregisterForNotificationsAsync(): Promise<void> {\n if (!PushTokenManager.unregisterForNotificationsAsync) {\n throw new UnavailabilityError('ExpoNotifications', 'unregisterForNotificationsAsync');\n }\n return PushTokenManager.unregisterForNotificationsAsync();\n}\n"]}
|
|
@@ -45,6 +45,13 @@ EX_EXPORT_METHOD_AS(getDevicePushTokenAsync,
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
EX_EXPORT_METHOD_AS(unregisterForNotificationsAsync,
|
|
49
|
+
unregisterForNotificationsAsync:(EXPromiseResolveBlock)resolve reject:(EXPromiseRejectBlock)reject)
|
|
50
|
+
{
|
|
51
|
+
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
|
|
52
|
+
resolve(nil);
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
# pragma mark - EXModuleRegistryConsumer
|
|
49
56
|
|
|
50
57
|
- (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-notifications",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"description": "Notifications module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"expo": "*"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "702fddee92d0d96c29fc8144fa08d07ba0995492"
|
|
62
62
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';
|
|
2
|
+
export { default as unregisterForNotificationsAsync } from './unregisterForNotificationsAsync';
|
|
2
3
|
export { default as getExpoPushTokenAsync } from './getExpoPushTokenAsync';
|
|
3
4
|
export { default as getPresentedNotificationsAsync } from './getPresentedNotificationsAsync';
|
|
4
5
|
export { default as presentNotificationAsync } from './presentNotificationAsync';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
2
|
+
|
|
3
|
+
import PushTokenManager from './PushTokenManager';
|
|
4
|
+
|
|
5
|
+
export default async function unregisterForNotificationsAsync(): Promise<void> {
|
|
6
|
+
if (!PushTokenManager.unregisterForNotificationsAsync) {
|
|
7
|
+
throw new UnavailabilityError('ExpoNotifications', 'unregisterForNotificationsAsync');
|
|
8
|
+
}
|
|
9
|
+
return PushTokenManager.unregisterForNotificationsAsync();
|
|
10
|
+
}
|