expo-notifications 0.16.1 → 0.17.0

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.
Files changed (25) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/AndroidManifest.xml +1 -0
  4. package/android/src/main/java/expo/modules/notifications/permissions/NotificationPermissionsModule.kt +144 -0
  5. package/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt +1 -1
  6. package/build/NotificationPermissions.d.ts +1 -1
  7. package/build/NotificationPermissions.js +1 -1
  8. package/build/NotificationPermissions.js.map +1 -1
  9. package/ios/EXNotifications.podspec +1 -1
  10. package/ios/EXNotifications.xcframework/ios-arm64/EXNotifications.framework/EXNotifications +0 -0
  11. package/ios/EXNotifications.xcframework/ios-arm64/EXNotifications.framework/Info.plist +0 -0
  12. package/ios/EXNotifications.xcframework/ios-arm64_x86_64-simulator/EXNotifications.framework/EXNotifications +0 -0
  13. package/ios/EXNotifications.xcframework/ios-arm64_x86_64-simulator/EXNotifications.framework/Info.plist +0 -0
  14. package/package.json +5 -6
  15. package/plugin/build/withNotifications.d.ts +1 -1
  16. package/plugin/build/withNotifications.js +1 -1
  17. package/plugin/build/withNotificationsAndroid.d.ts +2 -2
  18. package/plugin/build/withNotificationsAndroid.js +3 -5
  19. package/plugin/build/withNotificationsIOS.d.ts +1 -1
  20. package/plugin/build/withNotificationsIOS.js +1 -1
  21. package/plugin/src/withNotifications.ts +1 -1
  22. package/plugin/src/withNotificationsAndroid.ts +3 -3
  23. package/plugin/src/withNotificationsIOS.ts +1 -1
  24. package/src/NotificationPermissions.ts +1 -1
  25. package/android/src/main/java/expo/modules/notifications/permissions/NotificationPermissionsModule.java +0 -74
package/CHANGELOG.md CHANGED
@@ -10,6 +10,23 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.17.0 — 2022-10-25
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - [plugin] Upgrade minimum runtime requirement to Node 14 (LTS). ([#18204](https://github.com/expo/expo/pull/18204) by [@EvanBacon](https://github.com/EvanBacon))
18
+ - Bumped iOS deployment target to 13.0 and deprecated support for iOS 12. ([#18873](https://github.com/expo/expo/pull/18873) by [@tsapeta](https://github.com/tsapeta))
19
+
20
+ ### 🐛 Bug fixes
21
+
22
+ - Fixed build error for setting `compileSdkVersion` to 33. ([#19432](https://github.com/expo/expo/pull/19432) by [@kudo](https://github.com/kudo))
23
+ - Fixed the `POST_NOTIFICATIONS` runtime permission integration when `targerSdkVersion` is set to 33. ([#19672](https://github.com/expo/expo/pull/19672) by [@kudo](https://github.com/kudo), [@kudo](https://github.com/kudo))
24
+
25
+ ### 💡 Others
26
+
27
+ - [plugin] Migrate import from @expo/config-plugins to expo/config-plugins and @expo/config-types to expo/config. ([#18855](https://github.com/expo/expo/pull/18855) by [@brentvatne](https://github.com/brentvatne))
28
+ - Drop `@expo/config-plugins` dependency in favor of peer dependency on `expo`. ([#18595](https://github.com/expo/expo/pull/18595) by [@EvanBacon](https://github.com/EvanBacon))
29
+
13
30
  ## 0.16.1 — 2022-07-16
14
31
 
15
32
  _This version does not introduce any user-facing changes._
@@ -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.16.1'
6
+ version = '0.17.0'
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.16.1'
77
+ versionName '0.17.0'
78
78
  }
79
79
 
80
80
  lintOptions {
@@ -2,6 +2,7 @@
2
2
  package="expo.modules.notifications">
3
3
 
4
4
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
5
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
5
6
 
6
7
  <application>
7
8
  <service
@@ -0,0 +1,144 @@
1
+ package expo.modules.notifications.permissions
2
+
3
+ import android.app.NotificationManager
4
+ import android.content.Context
5
+ import android.os.Build
6
+ import androidx.annotation.RequiresApi
7
+ import androidx.core.app.NotificationManagerCompat
8
+ import androidx.core.os.bundleOf
9
+ import expo.modules.core.ExportedModule
10
+ import expo.modules.core.ModuleRegistry
11
+ import expo.modules.core.Promise
12
+ import expo.modules.core.arguments.ReadableArguments
13
+ import expo.modules.core.interfaces.ExpoMethod
14
+ import expo.modules.interfaces.permissions.Permissions
15
+ import expo.modules.interfaces.permissions.PermissionsResponse
16
+ import expo.modules.interfaces.permissions.PermissionsStatus
17
+
18
+ class NotificationPermissionsModule(context: Context?) : ExportedModule(context) {
19
+ private lateinit var moduleRegistry: ModuleRegistry
20
+
21
+ override fun onCreate(moduleRegistry: ModuleRegistry) {
22
+ this.moduleRegistry = moduleRegistry
23
+ }
24
+
25
+ override fun getName(): String {
26
+ return EXPORTED_NAME
27
+ }
28
+
29
+ @ExpoMethod
30
+ fun getPermissionsAsync(promise: Promise) {
31
+ if (context.applicationContext.applicationInfo.targetSdkVersion >= 33 && Build.VERSION.SDK_INT >= 33) {
32
+ getPermissionsWithPromiseImplApi33(promise)
33
+ } else {
34
+ getPermissionsWithPromiseImplClassic(promise)
35
+ }
36
+ }
37
+
38
+ @ExpoMethod
39
+ fun requestPermissionsAsync(permissionsTypes: ReadableArguments?, promise: Promise) {
40
+ if (context.applicationContext.applicationInfo.targetSdkVersion >= 33 && Build.VERSION.SDK_INT >= 33) {
41
+ requestPermissionsWithPromiseImplApi33(promise)
42
+ } else {
43
+ getPermissionsWithPromiseImplClassic(promise)
44
+ }
45
+ }
46
+
47
+ @RequiresApi(33)
48
+ private fun getPermissionsWithPromiseImplApi33(promise: Promise) {
49
+ val permissionManager = moduleRegistry.getModule(Permissions::class.java)
50
+ if (permissionManager == null) {
51
+ promise.reject("E_NO_PERMISSIONS", "Permissions module is null. Are you sure all the installed Expo modules are properly linked?")
52
+ return
53
+ }
54
+
55
+ permissionManager.getPermissions(
56
+ { permissionsMap: Map<String, PermissionsResponse> ->
57
+ val managerCompat = NotificationManagerCompat.from(context)
58
+ val areEnabled = managerCompat.areNotificationsEnabled()
59
+ val platformBundle = bundleOf(
60
+ IMPORTANCE_KEY to managerCompat.importance,
61
+ ).apply {
62
+ val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
63
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && notificationManager != null) {
64
+ putInt(INTERRUPTION_FILTER_KEY, notificationManager.currentInterruptionFilter)
65
+ }
66
+ }
67
+
68
+ val areAllGranted = permissionsMap.all { (_, response) -> response.status == PermissionsStatus.GRANTED }
69
+ val areAllDenied = permissionsMap.all { (_, response) -> response.status == PermissionsStatus.DENIED }
70
+ val canAskAgain = permissionsMap.all { (_, response) -> response.canAskAgain }
71
+ val status = when {
72
+ areAllDenied -> PermissionsStatus.DENIED.status
73
+ !areEnabled -> PermissionsStatus.DENIED.status
74
+ areAllGranted -> PermissionsStatus.GRANTED.status
75
+ else -> PermissionsStatus.UNDETERMINED.status
76
+ }
77
+
78
+ promise.resolve(
79
+ bundleOf(
80
+ PermissionsResponse.EXPIRES_KEY to PermissionsResponse.PERMISSION_EXPIRES_NEVER,
81
+ PermissionsResponse.STATUS_KEY to status,
82
+ PermissionsResponse.CAN_ASK_AGAIN_KEY to canAskAgain,
83
+ PermissionsResponse.GRANTED_KEY to areAllGranted,
84
+ ANDROID_RESPONSE_KEY to platformBundle,
85
+ )
86
+ )
87
+ },
88
+ *PERMISSIONS
89
+ )
90
+ }
91
+
92
+ private fun getPermissionsWithPromiseImplClassic(promise: Promise) {
93
+ val managerCompat = NotificationManagerCompat.from(context)
94
+ val areEnabled = managerCompat.areNotificationsEnabled()
95
+ val status = if (areEnabled) PermissionsStatus.GRANTED else PermissionsStatus.DENIED
96
+ val platformBundle = bundleOf(
97
+ IMPORTANCE_KEY to managerCompat.importance,
98
+ ).apply {
99
+ val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
100
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && notificationManager != null) {
101
+ putInt(INTERRUPTION_FILTER_KEY, notificationManager.currentInterruptionFilter)
102
+ }
103
+ }
104
+
105
+ promise.resolve(
106
+ bundleOf(
107
+ PermissionsResponse.EXPIRES_KEY to PermissionsResponse.PERMISSION_EXPIRES_NEVER,
108
+ PermissionsResponse.STATUS_KEY to status.status,
109
+ PermissionsResponse.CAN_ASK_AGAIN_KEY to areEnabled,
110
+ PermissionsResponse.GRANTED_KEY to (status == PermissionsStatus.GRANTED),
111
+ ANDROID_RESPONSE_KEY to platformBundle,
112
+ )
113
+ )
114
+ }
115
+
116
+ @RequiresApi(33)
117
+ private fun requestPermissionsWithPromiseImplApi33(promise: Promise) {
118
+ val permissionManager = moduleRegistry.getModule(Permissions::class.java)
119
+ if (permissionManager == null) {
120
+ promise.reject("E_NO_PERMISSIONS", "Permissions module is null. Are you sure all the installed Expo modules are properly linked?")
121
+ return
122
+ }
123
+
124
+ permissionManager.askForPermissions(
125
+ {
126
+ getPermissionsWithPromiseImplApi33(promise)
127
+ },
128
+ *PERMISSIONS
129
+ )
130
+ }
131
+
132
+ companion object {
133
+ private const val EXPORTED_NAME = "ExpoNotificationPermissionsModule"
134
+ private const val ANDROID_RESPONSE_KEY = "android"
135
+ private const val IMPORTANCE_KEY = "importance"
136
+ private const val INTERRUPTION_FILTER_KEY = "interruptionFilter"
137
+
138
+ private val PERMISSIONS: Array<String>
139
+ /**
140
+ * TODO: Use {@link Android.Manifest.permission.POST_NOTIFICATIONS} when we support compileSdkVersion 33
141
+ */
142
+ get() = arrayOf("android.permission.POST_NOTIFICATIONS")
143
+ }
144
+ }
@@ -502,7 +502,7 @@ open class NotificationsService : BroadcastReceiver() {
502
502
  val notification = intent.getParcelableExtra<Notification>(NOTIFICATION_KEY) ?: throw IllegalArgumentException("$NOTIFICATION_KEY not found in the intent extras.")
503
503
  val action = intent.getParcelableExtra<NotificationAction>(NOTIFICATION_ACTION_KEY) ?: throw IllegalArgumentException("$NOTIFICATION_ACTION_KEY not found in the intent extras.")
504
504
  val response = if (action is TextInputNotificationAction) {
505
- val userText = action.placeholder ?: RemoteInput.getResultsFromIntent(intent).getString(USER_TEXT_RESPONSE_KEY)
505
+ val userText = action.placeholder ?: RemoteInput.getResultsFromIntent(intent)?.getString(USER_TEXT_RESPONSE_KEY) ?: ""
506
506
  TextInputNotificationResponse(action, notification, userText)
507
507
  } else {
508
508
  NotificationResponse(action, notification)
@@ -7,7 +7,7 @@ export declare function requestPermissionsAsync(permissions?: NotificationPermis
7
7
  *
8
8
  * @example
9
9
  * ```ts
10
- * const [status, requestPermission] = Notifications.usePermissions();
10
+ * const [permissionResponse, requestPermission] = Notifications.usePermissions();
11
11
  * ```
12
12
  */
13
13
  export declare const usePermissions: (options?: import("expo-modules-core").PermissionHookOptions<NotificationPermissionsRequest> | undefined) => [NotificationPermissionsStatus | null, () => Promise<NotificationPermissionsStatus>, () => Promise<NotificationPermissionsStatus>];
@@ -27,7 +27,7 @@ export async function requestPermissionsAsync(permissions) {
27
27
  *
28
28
  * @example
29
29
  * ```ts
30
- * const [status, requestPermission] = Notifications.usePermissions();
30
+ * const [permissionResponse, requestPermission] = Notifications.usePermissions();
31
31
  * ```
32
32
  */
33
33
  export const usePermissions = createPermissionHook({
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationPermissions.js","sourceRoot":"","sources":["../src/NotificationPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAMxF,OAAO,6BAA6B,MAAM,iCAAiC,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,6BAA6B,CAAC,mBAAmB,EAAE;QACtD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;KACvE;IAED,OAAO,MAAM,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,WAA4C;IACxF,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE;QAC1D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;KAC3E;IAED,MAAM,oBAAoB,GAAG,WAAW,IAAI;QAC1C,GAAG,EAAE;YACH,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IACF,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,MAAM,6BAA6B,CAAC,uBAAuB,CAAC,4BAA4B,CAAC,CAAC;AACnG,CAAC;AAED,cAAc;AACd;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAGhD;IACA,aAAa,EAAE,uBAAuB;IACtC,SAAS,EAAE,mBAAmB;CAC/B,CAAC,CAAC","sourcesContent":["import { createPermissionHook, Platform, UnavailabilityError } from 'expo-modules-core';\n\nimport {\n NotificationPermissionsRequest,\n NotificationPermissionsStatus,\n} from './NotificationPermissions.types';\nimport NotificationPermissionsModule from './NotificationPermissionsModule';\n\nexport async function getPermissionsAsync() {\n if (!NotificationPermissionsModule.getPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'getPermissionsAsync');\n }\n\n return await NotificationPermissionsModule.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(permissions?: NotificationPermissionsRequest) {\n if (!NotificationPermissionsModule.requestPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'requestPermissionsAsync');\n }\n\n const requestedPermissions = permissions ?? {\n ios: {\n allowAlert: true,\n allowBadge: true,\n allowSound: true,\n },\n };\n const requestedPlatformPermissions = requestedPermissions[Platform.OS];\n return await NotificationPermissionsModule.requestPermissionsAsync(requestedPlatformPermissions);\n}\n\n// @needsAudit\n/**\n * Check or request permissions to send and receive push notifications.\n * This uses both `requestPermissionsAsync` and `getPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Notifications.usePermissions();\n * ```\n */\nexport const usePermissions = createPermissionHook<\n NotificationPermissionsStatus,\n NotificationPermissionsRequest\n>({\n requestMethod: requestPermissionsAsync,\n getMethod: getPermissionsAsync,\n});\n"]}
1
+ {"version":3,"file":"NotificationPermissions.js","sourceRoot":"","sources":["../src/NotificationPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAMxF,OAAO,6BAA6B,MAAM,iCAAiC,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,6BAA6B,CAAC,mBAAmB,EAAE;QACtD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;KACvE;IAED,OAAO,MAAM,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,WAA4C;IACxF,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE;QAC1D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;KAC3E;IAED,MAAM,oBAAoB,GAAG,WAAW,IAAI;QAC1C,GAAG,EAAE;YACH,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IACF,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,MAAM,6BAA6B,CAAC,uBAAuB,CAAC,4BAA4B,CAAC,CAAC;AACnG,CAAC;AAED,cAAc;AACd;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAGhD;IACA,aAAa,EAAE,uBAAuB;IACtC,SAAS,EAAE,mBAAmB;CAC/B,CAAC,CAAC","sourcesContent":["import { createPermissionHook, Platform, UnavailabilityError } from 'expo-modules-core';\n\nimport {\n NotificationPermissionsRequest,\n NotificationPermissionsStatus,\n} from './NotificationPermissions.types';\nimport NotificationPermissionsModule from './NotificationPermissionsModule';\n\nexport async function getPermissionsAsync() {\n if (!NotificationPermissionsModule.getPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'getPermissionsAsync');\n }\n\n return await NotificationPermissionsModule.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(permissions?: NotificationPermissionsRequest) {\n if (!NotificationPermissionsModule.requestPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'requestPermissionsAsync');\n }\n\n const requestedPermissions = permissions ?? {\n ios: {\n allowAlert: true,\n allowBadge: true,\n allowSound: true,\n },\n };\n const requestedPlatformPermissions = requestedPermissions[Platform.OS];\n return await NotificationPermissionsModule.requestPermissionsAsync(requestedPlatformPermissions);\n}\n\n// @needsAudit\n/**\n * Check or request permissions to send and receive push notifications.\n * This uses both `requestPermissionsAsync` and `getPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [permissionResponse, requestPermission] = Notifications.usePermissions();\n * ```\n */\nexport const usePermissions = createPermissionHook<\n NotificationPermissionsStatus,\n NotificationPermissionsRequest\n>({\n requestMethod: requestPermissionsAsync,\n getMethod: getPermissionsAsync,\n});\n"]}
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
10
10
  s.license = package['license']
11
11
  s.author = package['author']
12
12
  s.homepage = package['homepage']
13
- s.platform = :ios, '12.0'
13
+ s.platform = :ios, '13.0'
14
14
  s.source = { git: 'https://github.com/expo/expo.git' }
15
15
  s.static_framework = true
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-notifications",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Notifications module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -37,26 +37,25 @@
37
37
  "preset": "expo-module-scripts/ios"
38
38
  },
39
39
  "dependencies": {
40
- "@expo/config-plugins": "~5.0.0",
41
40
  "@expo/image-utils": "^0.3.18",
42
41
  "@ide/backoff": "^1.0.0",
43
42
  "abort-controller": "^3.0.0",
44
43
  "assert": "^2.0.0",
45
44
  "badgin": "^1.1.5",
46
- "expo-application": "~4.2.0",
47
- "expo-constants": "~13.2.0",
45
+ "expo-application": "~5.0.0",
46
+ "expo-constants": "~14.0.0",
48
47
  "fs-extra": "^9.1.0",
49
48
  "uuid": "^3.4.0"
50
49
  },
51
50
  "devDependencies": {
52
51
  "@types/node-fetch": "^2.5.7",
53
52
  "@types/uuid": "^3.4.7",
54
- "expo-module-scripts": "^2.0.0",
53
+ "expo-module-scripts": "^3.0.0",
55
54
  "memfs": "^3.2.0",
56
55
  "node-fetch": "^2.6.7"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "expo": "*"
60
59
  },
61
- "gitHead": "c6678c65b68e45062d49a2deea8e822f69388278"
60
+ "gitHead": "eab2b09c735fb0fc2bf734a3f29a6593adba3838"
62
61
  }
@@ -1,4 +1,4 @@
1
- import { ConfigPlugin } from '@expo/config-plugins';
1
+ import { ConfigPlugin } from 'expo/config-plugins';
2
2
  export declare type NotificationsPluginProps = {
3
3
  /**
4
4
  * Local path to an image to use as the icon for push notifications.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_plugins_1 = require("@expo/config-plugins");
3
+ const config_plugins_1 = require("expo/config-plugins");
4
4
  const withNotificationsAndroid_1 = require("./withNotificationsAndroid");
5
5
  const withNotificationsIOS_1 = require("./withNotificationsIOS");
6
6
  const pkg = require('expo-notifications/package.json');
@@ -1,5 +1,5 @@
1
- import { AndroidConfig, ConfigPlugin } from '@expo/config-plugins';
2
- import { ExpoConfig } from '@expo/config-types';
1
+ import { ExpoConfig } from 'expo/config';
2
+ import { AndroidConfig, ConfigPlugin } from 'expo/config-plugins';
3
3
  import { NotificationsPluginProps } from './withNotifications';
4
4
  declare type DPIString = 'mdpi' | 'hdpi' | 'xhdpi' | 'xxhdpi' | 'xxxhdpi';
5
5
  declare type dpiMap = Record<DPIString, {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNotificationsAndroid = exports.setNotificationSounds = exports.setNotificationIconAsync = exports.setNotificationIconColor = exports.getNotificationColor = exports.getNotificationIcon = exports.withNotificationSounds = exports.withNotificationManifest = exports.withNotificationIconColor = exports.withNotificationIcons = exports.NOTIFICATION_ICON_COLOR_RESOURCE = exports.NOTIFICATION_ICON_COLOR = exports.NOTIFICATION_ICON_RESOURCE = exports.NOTIFICATION_ICON = exports.META_DATA_NOTIFICATION_ICON_COLOR = exports.META_DATA_NOTIFICATION_ICON = exports.dpiValues = exports.ANDROID_RES_PATH = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
4
  const image_utils_1 = require("@expo/image-utils");
5
+ const config_plugins_1 = require("expo/config-plugins");
6
6
  const fs_1 = require("fs");
7
7
  const path_1 = require("path");
8
8
  const { Colors } = config_plugins_1.AndroidConfig;
@@ -65,13 +65,11 @@ const withNotificationSounds = (config, { sounds }) => {
65
65
  };
66
66
  exports.withNotificationSounds = withNotificationSounds;
67
67
  function getNotificationIcon(config) {
68
- var _a;
69
- return ((_a = config.notification) === null || _a === void 0 ? void 0 : _a.icon) || null;
68
+ return config.notification?.icon || null;
70
69
  }
71
70
  exports.getNotificationIcon = getNotificationIcon;
72
71
  function getNotificationColor(config) {
73
- var _a;
74
- return ((_a = config.notification) === null || _a === void 0 ? void 0 : _a.color) || null;
72
+ return config.notification?.color || null;
75
73
  }
76
74
  exports.getNotificationColor = getNotificationColor;
77
75
  function setNotificationIconColor(color, colors) {
@@ -1,4 +1,4 @@
1
- import { ConfigPlugin, XcodeProject } from '@expo/config-plugins';
1
+ import { ConfigPlugin, XcodeProject } from 'expo/config-plugins';
2
2
  import { NotificationsPluginProps } from './withNotifications';
3
3
  export declare const withNotificationsIOS: ConfigPlugin<NotificationsPluginProps>;
4
4
  export declare const withNotificationSounds: ConfigPlugin<{
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setNotificationSounds = exports.withNotificationSounds = exports.withNotificationsIOS = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
4
+ const config_plugins_1 = require("expo/config-plugins");
5
5
  const fs_1 = require("fs");
6
6
  const path_1 = require("path");
7
7
  const ERROR_MSG_PREFIX = 'An error occurred while configuring iOS notifications. ';
@@ -1,4 +1,4 @@
1
- import { ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins';
1
+ import { ConfigPlugin, createRunOncePlugin } from 'expo/config-plugins';
2
2
 
3
3
  import { withNotificationsAndroid } from './withNotificationsAndroid';
4
4
  import { withNotificationsIOS } from './withNotificationsIOS';
@@ -1,12 +1,12 @@
1
+ import { generateImageAsync } from '@expo/image-utils';
2
+ import { ExpoConfig } from 'expo/config';
1
3
  import {
2
4
  AndroidConfig,
3
5
  ConfigPlugin,
4
6
  withDangerousMod,
5
7
  withAndroidColors,
6
8
  withAndroidManifest,
7
- } from '@expo/config-plugins';
8
- import { ExpoConfig } from '@expo/config-types';
9
- import { generateImageAsync } from '@expo/image-utils';
9
+ } from 'expo/config-plugins';
10
10
  import { writeFileSync, unlinkSync, copyFileSync, existsSync, mkdirSync } from 'fs';
11
11
  import { basename, resolve } from 'path';
12
12
 
@@ -4,7 +4,7 @@ import {
4
4
  IOSConfig,
5
5
  withXcodeProject,
6
6
  XcodeProject,
7
- } from '@expo/config-plugins';
7
+ } from 'expo/config-plugins';
8
8
  import { copyFileSync } from 'fs';
9
9
  import { basename, resolve } from 'path';
10
10
 
@@ -37,7 +37,7 @@ export async function requestPermissionsAsync(permissions?: NotificationPermissi
37
37
  *
38
38
  * @example
39
39
  * ```ts
40
- * const [status, requestPermission] = Notifications.usePermissions();
40
+ * const [permissionResponse, requestPermission] = Notifications.usePermissions();
41
41
  * ```
42
42
  */
43
43
  export const usePermissions = createPermissionHook<
@@ -1,74 +0,0 @@
1
- package expo.modules.notifications.permissions;
2
-
3
- import android.app.NotificationManager;
4
- import android.content.Context;
5
- import android.os.Build;
6
- import android.os.Bundle;
7
-
8
- import expo.modules.core.ExportedModule;
9
- import expo.modules.core.Promise;
10
- import expo.modules.core.arguments.ReadableArguments;
11
- import expo.modules.core.interfaces.ExpoMethod;
12
-
13
- import androidx.core.app.NotificationManagerCompat;
14
-
15
- import expo.modules.interfaces.permissions.PermissionsStatus;
16
-
17
- import static expo.modules.interfaces.permissions.PermissionsResponse.CAN_ASK_AGAIN_KEY;
18
- import static expo.modules.interfaces.permissions.PermissionsResponse.EXPIRES_KEY;
19
- import static expo.modules.interfaces.permissions.PermissionsResponse.GRANTED_KEY;
20
- import static expo.modules.interfaces.permissions.PermissionsResponse.PERMISSION_EXPIRES_NEVER;
21
- import static expo.modules.interfaces.permissions.PermissionsResponse.STATUS_KEY;
22
-
23
- public class NotificationPermissionsModule extends ExportedModule {
24
- private static final String EXPORTED_NAME = "ExpoNotificationPermissionsModule";
25
-
26
- private static final String ANDROID_RESPONSE_KEY = "android";
27
- private static final String IMPORTANCE_KEY = "importance";
28
- private static final String INTERRUPTION_FILTER_KEY = "interruptionFilter";
29
-
30
- public NotificationPermissionsModule(Context context) {
31
- super(context);
32
- }
33
-
34
- @Override
35
- public String getName() {
36
- return EXPORTED_NAME;
37
- }
38
-
39
- @ExpoMethod
40
- public void getPermissionsAsync(final Promise promise) {
41
- promise.resolve(getPermissionsBundle());
42
- }
43
-
44
- @ExpoMethod
45
- public void requestPermissionsAsync(@SuppressWarnings("unused") final ReadableArguments permissionsTypes, final Promise promise) {
46
- promise.resolve(getPermissionsBundle());
47
- }
48
-
49
- private Bundle getPermissionsBundle() {
50
- NotificationManagerCompat managerCompat = NotificationManagerCompat.from(getContext());
51
- boolean areEnabled = managerCompat.areNotificationsEnabled();
52
- PermissionsStatus status = areEnabled ? PermissionsStatus.GRANTED : PermissionsStatus.DENIED;
53
-
54
- Bundle permissions = new Bundle();
55
-
56
- permissions.putString(EXPIRES_KEY, PERMISSION_EXPIRES_NEVER);
57
- permissions.putBoolean(CAN_ASK_AGAIN_KEY, areEnabled);
58
- permissions.putString(STATUS_KEY, status.getStatus());
59
- permissions.putBoolean(GRANTED_KEY, PermissionsStatus.GRANTED == status);
60
-
61
- Bundle platformPermissions = new Bundle();
62
-
63
- platformPermissions.putInt(IMPORTANCE_KEY, managerCompat.getImportance());
64
-
65
- NotificationManager manager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
66
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && manager != null) {
67
- platformPermissions.putInt(INTERRUPTION_FILTER_KEY, manager.getCurrentInterruptionFilter());
68
- }
69
-
70
- permissions.putBundle(ANDROID_RESPONSE_KEY, platformPermissions);
71
-
72
- return permissions;
73
- }
74
- }