expo-targets 0.3.0 → 0.3.2
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/README.md +5 -4
- package/android/build.gradle +4 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsActivityHolder.kt +37 -0
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsExtensionModule.kt +59 -8
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsHarnessActivity.kt +28 -0
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsReactTargetActivity.kt +123 -0
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsSharedIntent.kt +89 -0
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsTargetActivity.kt +363 -0
- package/android/src/main/java/expo/modules/targets/liveActivity/ExpoTargetsLiveActivityModule.kt +153 -0
- package/android/src/main/java/expo/modules/targets/notification/ExpoTargetsNotificationModule.kt +134 -0
- package/android/src/main/java/expo/modules/targets/notification/ExpoTargetsNotificationRouter.kt +192 -0
- package/android/src/main/java/expo/modules/targets/notification/ExpoTargetsNotificationService.kt +92 -0
- package/android/src/main/java/expo/modules/targets/storage/ExpoTargetsStorageModule.kt +127 -42
- package/android/src/main/java/expo/modules/targets/system/ExpoTargetsAutofillService.kt +28 -0
- package/android/src/main/java/expo/modules/targets/system/ExpoTargetsCallScreeningService.kt +47 -0
- package/android/src/main/java/expo/modules/targets/system/ExpoTargetsDocumentsProvider.kt +148 -0
- package/android/src/main/java/expo/modules/targets/system/ExpoTargetsFileProviderUiActivity.kt +47 -0
- package/android/src/main/java/expo/modules/targets/system/ExpoTargetsInputMethodService.kt +41 -0
- package/android/src/main/java/expo/modules/targets/system/ExpoTargetsPrintService.kt +34 -0
- package/android/src/main/java/expo/modules/targets/system/ExpoTargetsVpnService.kt +32 -0
- package/android/src/main/res/layout/expo_targets_notification_content.xml +29 -0
- package/android/src/main/res/xml/expo_targets_autofill_service.xml +3 -0
- package/android/src/main/res/xml/expo_targets_method.xml +9 -0
- package/android/src/main/res/xml/expo_targets_print_service.xml +4 -0
- package/build/metro/src/withTargets.d.ts.map +1 -1
- package/build/metro/src/withTargets.js +37 -11
- package/build/metro/src/withTargets.js.map +1 -1
- package/build/plugin/src/android/activationMime.d.ts +12 -0
- package/build/plugin/src/android/activationMime.d.ts.map +1 -0
- package/build/plugin/src/android/activationMime.js +47 -0
- package/build/plugin/src/android/activationMime.js.map +1 -0
- package/build/plugin/src/android/resolveUserClass.d.ts +14 -0
- package/build/plugin/src/android/resolveUserClass.d.ts.map +1 -0
- package/build/plugin/src/android/resolveUserClass.js +48 -0
- package/build/plugin/src/android/resolveUserClass.js.map +1 -0
- package/build/plugin/src/android/targetSourceSets.d.ts +9 -0
- package/build/plugin/src/android/targetSourceSets.d.ts.map +1 -0
- package/build/plugin/src/android/targetSourceSets.js +90 -0
- package/build/plugin/src/android/targetSourceSets.js.map +1 -0
- package/build/plugin/src/android/withAndroidNotification.d.ts +12 -0
- package/build/plugin/src/android/withAndroidNotification.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidNotification.js +192 -0
- package/build/plugin/src/android/withAndroidNotification.js.map +1 -0
- package/build/plugin/src/android/withAndroidShareAction.d.ts +11 -0
- package/build/plugin/src/android/withAndroidShareAction.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidShareAction.js +172 -0
- package/build/plugin/src/android/withAndroidShareAction.js.map +1 -0
- package/build/plugin/src/android/withAndroidSystemService.d.ts +12 -0
- package/build/plugin/src/android/withAndroidSystemService.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidSystemService.js +332 -0
- package/build/plugin/src/android/withAndroidSystemService.js.map +1 -0
- package/build/plugin/src/android/withAndroidTarget.d.ts +2 -1
- package/build/plugin/src/android/withAndroidTarget.d.ts.map +1 -1
- package/build/plugin/src/android/withAndroidTarget.js +25 -3
- package/build/plugin/src/android/withAndroidTarget.js.map +1 -1
- package/build/plugin/src/android/withAndroidTargetsConfig.d.ts +9 -0
- package/build/plugin/src/android/withAndroidTargetsConfig.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidTargetsConfig.js +52 -0
- package/build/plugin/src/android/withAndroidTargetsConfig.js.map +1 -0
- package/build/plugin/src/codegen/collectRuntimeConfigs.d.ts +3 -0
- package/build/plugin/src/codegen/collectRuntimeConfigs.d.ts.map +1 -1
- package/build/plugin/src/codegen/collectRuntimeConfigs.js.map +1 -1
- package/build/plugin/src/codegen/index.d.ts +1 -1
- package/build/plugin/src/codegen/index.d.ts.map +1 -1
- package/build/plugin/src/codegen/index.js +2 -1
- package/build/plugin/src/codegen/index.js.map +1 -1
- package/build/plugin/src/codegen/typedTargets.d.ts +11 -1
- package/build/plugin/src/codegen/typedTargets.d.ts.map +1 -1
- package/build/plugin/src/codegen/typedTargets.js +102 -12
- package/build/plugin/src/codegen/typedTargets.js.map +1 -1
- package/build/plugin/src/config.d.ts +37 -6
- package/build/plugin/src/config.d.ts.map +1 -1
- package/build/plugin/src/config.js.map +1 -1
- package/build/plugin/src/domain/characteristics.d.ts +8 -0
- package/build/plugin/src/domain/characteristics.d.ts.map +1 -1
- package/build/plugin/src/domain/characteristics.js +81 -10
- package/build/plugin/src/domain/characteristics.js.map +1 -1
- package/build/plugin/src/domain/index.d.ts +1 -1
- package/build/plugin/src/domain/index.d.ts.map +1 -1
- package/build/plugin/src/domain/index.js.map +1 -1
- package/build/plugin/src/ios/apply/podfile/podfile.d.ts.map +1 -1
- package/build/plugin/src/ios/apply/podfile/podfile.js +21 -4
- package/build/plugin/src/ios/apply/podfile/podfile.js.map +1 -1
- package/build/plugin/src/ios/cng/appShortcutsCodegen.d.ts +1 -1
- package/build/plugin/src/ios/cng/appShortcutsCodegen.d.ts.map +1 -1
- package/build/plugin/src/ios/cng/appShortcutsCodegen.js +1 -1
- package/build/plugin/src/ios/cng/appShortcutsCodegen.js.map +1 -1
- package/build/plugin/src/ios/plan/swiftSources.d.ts.map +1 -1
- package/build/plugin/src/ios/plan/swiftSources.js +10 -0
- package/build/plugin/src/ios/plan/swiftSources.js.map +1 -1
- package/build/plugin/src/ios/plan/types.d.ts +6 -0
- package/build/plugin/src/ios/plan/types.d.ts.map +1 -1
- package/build/plugin/src/ios/utils/reactNativeSwift.d.ts +3 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.d.ts.map +1 -1
- package/build/plugin/src/ios/utils/reactNativeSwift.js +3 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.js.map +1 -1
- package/build/plugin/src/resolveExcludedPackages.d.ts +15 -0
- package/build/plugin/src/resolveExcludedPackages.d.ts.map +1 -0
- package/build/plugin/src/resolveExcludedPackages.js +30 -0
- package/build/plugin/src/resolveExcludedPackages.js.map +1 -0
- package/build/plugin/src/withTargetsDir.d.ts +5 -0
- package/build/plugin/src/withTargetsDir.d.ts.map +1 -1
- package/build/plugin/src/withTargetsDir.js +114 -47
- package/build/plugin/src/withTargetsDir.js.map +1 -1
- package/build/src/Target.d.ts +11 -6
- package/build/src/Target.d.ts.map +1 -1
- package/build/src/Target.js +4 -1
- package/build/src/Target.js.map +1 -1
- package/build/src/generatedNames.d.ts +23 -0
- package/build/src/generatedNames.d.ts.map +1 -0
- package/build/src/generatedNames.js +3 -0
- package/build/src/generatedNames.js.map +1 -0
- package/build/src/index.d.ts +8 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +43 -17
- package/build/src/index.js.map +1 -1
- package/build/src/modules/extension/index.d.ts +1 -0
- package/build/src/modules/extension/index.d.ts.map +1 -1
- package/build/src/modules/extension/index.js +9 -5
- package/build/src/modules/extension/index.js.map +1 -1
- package/build/src/modules/extensionBundle/ExtensionUpdates.d.ts +72 -0
- package/build/src/modules/extensionBundle/ExtensionUpdates.d.ts.map +1 -0
- package/build/src/modules/extensionBundle/ExtensionUpdates.js +165 -0
- package/build/src/modules/extensionBundle/ExtensionUpdates.js.map +1 -0
- package/build/src/modules/extensionBundle/ExtensionUpdatesApi.d.ts +33 -0
- package/build/src/modules/extensionBundle/ExtensionUpdatesApi.d.ts.map +1 -0
- package/build/src/modules/extensionBundle/ExtensionUpdatesApi.js +87 -0
- package/build/src/modules/extensionBundle/ExtensionUpdatesApi.js.map +1 -0
- package/build/src/modules/extensionBundle/constants.d.ts +21 -0
- package/build/src/modules/extensionBundle/constants.d.ts.map +1 -0
- package/build/src/modules/extensionBundle/constants.js +30 -0
- package/build/src/modules/extensionBundle/constants.js.map +1 -0
- package/build/src/modules/extensionBundle/enableExtensionUpdates.d.ts +42 -0
- package/build/src/modules/extensionBundle/enableExtensionUpdates.d.ts.map +1 -0
- package/build/src/modules/extensionBundle/enableExtensionUpdates.js +114 -0
- package/build/src/modules/extensionBundle/enableExtensionUpdates.js.map +1 -0
- package/build/src/modules/extensionBundle/fsInstall.d.ts +50 -0
- package/build/src/modules/extensionBundle/fsInstall.d.ts.map +1 -0
- package/build/src/modules/extensionBundle/fsInstall.js +180 -0
- package/build/src/modules/extensionBundle/fsInstall.js.map +1 -0
- package/build/src/modules/extensionBundle/nativeInstall.d.ts +12 -0
- package/build/src/modules/extensionBundle/nativeInstall.d.ts.map +1 -0
- package/build/src/modules/extensionBundle/nativeInstall.js +33 -0
- package/build/src/modules/extensionBundle/nativeInstall.js.map +1 -0
- package/build/src/modules/liveActivity/index.d.ts +13 -6
- package/build/src/modules/liveActivity/index.d.ts.map +1 -1
- package/build/src/modules/liveActivity/index.js +2 -2
- package/build/src/modules/liveActivity/index.js.map +1 -1
- package/build/src/modules/notification/index.d.ts +21 -0
- package/build/src/modules/notification/index.d.ts.map +1 -0
- package/build/src/modules/notification/index.js +32 -0
- package/build/src/modules/notification/index.js.map +1 -0
- package/build/src/modules/storage/index.d.ts +2 -0
- package/build/src/modules/storage/index.d.ts.map +1 -1
- package/build/src/modules/storage/index.js +11 -1
- package/build/src/modules/storage/index.js.map +1 -1
- package/cli/build/checks/easCredentials.d.ts +5 -0
- package/cli/build/checks/easCredentials.d.ts.map +1 -0
- package/cli/build/checks/easCredentials.js +150 -0
- package/cli/build/checks/easCredentials.js.map +1 -0
- package/cli/build/checks/heavyExclusions.d.ts +5 -0
- package/cli/build/checks/heavyExclusions.d.ts.map +1 -0
- package/cli/build/checks/heavyExclusions.js +186 -0
- package/cli/build/checks/heavyExclusions.js.map +1 -0
- package/cli/build/checks/nameSync.d.ts.map +1 -1
- package/cli/build/checks/nameSync.js +31 -2
- package/cli/build/checks/nameSync.js.map +1 -1
- package/cli/build/checks/plugin.js +1 -1
- package/cli/build/checks/plugin.js.map +1 -1
- package/cli/build/checks/updateScript.d.ts +7 -0
- package/cli/build/checks/updateScript.d.ts.map +1 -0
- package/cli/build/checks/updateScript.js +91 -0
- package/cli/build/checks/updateScript.js.map +1 -0
- package/cli/build/doctor.d.ts.map +1 -1
- package/cli/build/doctor.js +11 -1
- package/cli/build/doctor.js.map +1 -1
- package/cli/build/exportExtensionBundles.d.ts +21 -0
- package/cli/build/exportExtensionBundles.d.ts.map +1 -0
- package/cli/build/exportExtensionBundles.js +193 -0
- package/cli/build/exportExtensionBundles.js.map +1 -0
- package/cli/build/extensionBundle/constants.d.ts +21 -0
- package/cli/build/extensionBundle/constants.d.ts.map +1 -0
- package/cli/build/extensionBundle/constants.js +30 -0
- package/cli/build/extensionBundle/constants.js.map +1 -0
- package/cli/build/extensionBundle/fsInstall.d.ts +50 -0
- package/cli/build/extensionBundle/fsInstall.d.ts.map +1 -0
- package/cli/build/extensionBundle/fsInstall.js +180 -0
- package/cli/build/extensionBundle/fsInstall.js.map +1 -0
- package/cli/build/extensionBundle/hermesExport.d.ts +37 -0
- package/cli/build/extensionBundle/hermesExport.d.ts.map +1 -0
- package/cli/build/extensionBundle/hermesExport.js +112 -0
- package/cli/build/extensionBundle/hermesExport.js.map +1 -0
- package/cli/build/generate.d.ts.map +1 -1
- package/cli/build/generate.js +7 -1
- package/cli/build/generate.js.map +1 -1
- package/cli/build/index.js +53 -3
- package/cli/build/index.js.map +1 -1
- package/cli/build/scaffold/copyTemplate.d.ts +15 -0
- package/cli/build/scaffold/copyTemplate.d.ts.map +1 -0
- package/cli/build/scaffold/copyTemplate.js +109 -0
- package/cli/build/scaffold/copyTemplate.js.map +1 -0
- package/cli/build/scaffold/expoConfigIO.d.ts +15 -0
- package/cli/build/scaffold/expoConfigIO.d.ts.map +1 -0
- package/cli/build/scaffold/expoConfigIO.js +104 -0
- package/cli/build/scaffold/expoConfigIO.js.map +1 -0
- package/cli/build/scaffold/generateConfig.d.ts +13 -0
- package/cli/build/scaffold/generateConfig.d.ts.map +1 -0
- package/cli/build/scaffold/generateConfig.js +169 -0
- package/cli/build/scaffold/generateConfig.js.map +1 -0
- package/cli/build/scaffold/index.d.ts +3 -0
- package/cli/build/scaffold/index.d.ts.map +1 -0
- package/cli/build/scaffold/index.js +8 -0
- package/cli/build/scaffold/index.js.map +1 -0
- package/cli/build/scaffold/prompts.d.ts +3 -0
- package/cli/build/scaffold/prompts.d.ts.map +1 -0
- package/cli/build/scaffold/prompts.js +92 -0
- package/cli/build/scaffold/prompts.js.map +1 -0
- package/cli/build/scaffold/reactNativeTemplate.d.ts +3 -0
- package/cli/build/scaffold/reactNativeTemplate.d.ts.map +1 -0
- package/cli/build/scaffold/reactNativeTemplate.js +56 -0
- package/cli/build/scaffold/reactNativeTemplate.js.map +1 -0
- package/cli/build/scaffold/resolveAndroidPackage.d.ts +5 -0
- package/cli/build/scaffold/resolveAndroidPackage.d.ts.map +1 -0
- package/cli/build/scaffold/resolveAndroidPackage.js +42 -0
- package/cli/build/scaffold/resolveAndroidPackage.js.map +1 -0
- package/cli/build/scaffold/resolveAppGroup.d.ts +6 -0
- package/cli/build/scaffold/resolveAppGroup.d.ts.map +1 -0
- package/cli/build/scaffold/resolveAppGroup.js +68 -0
- package/cli/build/scaffold/resolveAppGroup.js.map +1 -0
- package/cli/build/scaffold/scaffoldTarget.d.ts +14 -0
- package/cli/build/scaffold/scaffoldTarget.d.ts.map +1 -0
- package/cli/build/scaffold/scaffoldTarget.js +267 -0
- package/cli/build/scaffold/scaffoldTarget.js.map +1 -0
- package/cli/build/scaffold/templates/android.d.ts +33 -0
- package/cli/build/scaffold/templates/android.d.ts.map +1 -0
- package/cli/build/scaffold/templates/android.js +117 -0
- package/cli/build/scaffold/templates/android.js.map +1 -0
- package/cli/build/scaffold/templates/ios.d.ts +20 -0
- package/cli/build/scaffold/templates/ios.d.ts.map +1 -0
- package/cli/build/scaffold/templates/ios.js +505 -0
- package/cli/build/scaffold/templates/ios.js.map +1 -0
- package/cli/build/scaffold/templates/liveActivity.d.ts +11 -0
- package/cli/build/scaffold/templates/liveActivity.d.ts.map +1 -0
- package/cli/build/scaffold/templates/liveActivity.js +71 -0
- package/cli/build/scaffold/templates/liveActivity.js.map +1 -0
- package/cli/build/scaffold/utils.d.ts +3 -0
- package/cli/build/scaffold/utils.d.ts.map +1 -0
- package/cli/build/scaffold/utils.js +15 -0
- package/cli/build/scaffold/utils.js.map +1 -0
- package/cli/build/scaffold/wireExpoConfig.d.ts +12 -0
- package/cli/build/scaffold/wireExpoConfig.d.ts.map +1 -0
- package/cli/build/scaffold/wireExpoConfig.js +49 -0
- package/cli/build/scaffold/wireExpoConfig.js.map +1 -0
- package/cli/build/scaffold/wireHost.d.ts +21 -0
- package/cli/build/scaffold/wireHost.d.ts.map +1 -0
- package/cli/build/scaffold/wireHost.js +89 -0
- package/cli/build/scaffold/wireHost.js.map +1 -0
- package/cli/build/scaffold/wireMetro.d.ts +11 -0
- package/cli/build/scaffold/wireMetro.d.ts.map +1 -0
- package/cli/build/scaffold/wireMetro.js +64 -0
- package/cli/build/scaffold/wireMetro.js.map +1 -0
- package/cli/build/scaffold/wirePackageJson.d.ts +2 -0
- package/cli/build/scaffold/wirePackageJson.d.ts.map +1 -0
- package/cli/build/scaffold/wirePackageJson.js +24 -0
- package/cli/build/scaffold/wirePackageJson.js.map +1 -0
- package/cli/build/types.d.ts +1 -0
- package/cli/build/types.d.ts.map +1 -1
- package/expo-module.config.json +4 -1
- package/ios/ExpoTargetsExtensionBundleModule.swift +172 -0
- package/ios/ExpoTargetsMessagesModule.swift +4 -3
- package/ios/ExpoTargetsStorage.podspec +1 -0
- package/ios/ExpoTargetsStorageModule.swift +13 -0
- package/metro/build/withTargets.d.ts.map +1 -1
- package/metro/build/withTargets.js +37 -11
- package/metro/build/withTargets.js.map +1 -1
- package/package.json +5 -1
- package/plugin/build/android/activationMime.d.ts +12 -0
- package/plugin/build/android/activationMime.d.ts.map +1 -0
- package/plugin/build/android/activationMime.js +47 -0
- package/plugin/build/android/activationMime.js.map +1 -0
- package/plugin/build/android/resolveUserClass.d.ts +14 -0
- package/plugin/build/android/resolveUserClass.d.ts.map +1 -0
- package/plugin/build/android/resolveUserClass.js +48 -0
- package/plugin/build/android/resolveUserClass.js.map +1 -0
- package/plugin/build/android/targetSourceSets.d.ts +9 -0
- package/plugin/build/android/targetSourceSets.d.ts.map +1 -0
- package/plugin/build/android/targetSourceSets.js +90 -0
- package/plugin/build/android/targetSourceSets.js.map +1 -0
- package/plugin/build/android/withAndroidNotification.d.ts +12 -0
- package/plugin/build/android/withAndroidNotification.d.ts.map +1 -0
- package/plugin/build/android/withAndroidNotification.js +192 -0
- package/plugin/build/android/withAndroidNotification.js.map +1 -0
- package/plugin/build/android/withAndroidShareAction.d.ts +11 -0
- package/plugin/build/android/withAndroidShareAction.d.ts.map +1 -0
- package/plugin/build/android/withAndroidShareAction.js +172 -0
- package/plugin/build/android/withAndroidShareAction.js.map +1 -0
- package/plugin/build/android/withAndroidSystemService.d.ts +12 -0
- package/plugin/build/android/withAndroidSystemService.d.ts.map +1 -0
- package/plugin/build/android/withAndroidSystemService.js +332 -0
- package/plugin/build/android/withAndroidSystemService.js.map +1 -0
- package/plugin/build/android/withAndroidTarget.d.ts +2 -1
- package/plugin/build/android/withAndroidTarget.d.ts.map +1 -1
- package/plugin/build/android/withAndroidTarget.js +25 -3
- package/plugin/build/android/withAndroidTarget.js.map +1 -1
- package/plugin/build/android/withAndroidTargetsConfig.d.ts +9 -0
- package/plugin/build/android/withAndroidTargetsConfig.d.ts.map +1 -0
- package/plugin/build/android/withAndroidTargetsConfig.js +52 -0
- package/plugin/build/android/withAndroidTargetsConfig.js.map +1 -0
- package/plugin/build/codegen/collectRuntimeConfigs.d.ts +3 -0
- package/plugin/build/codegen/collectRuntimeConfigs.d.ts.map +1 -1
- package/plugin/build/codegen/collectRuntimeConfigs.js.map +1 -1
- package/plugin/build/codegen/index.d.ts +1 -1
- package/plugin/build/codegen/index.d.ts.map +1 -1
- package/plugin/build/codegen/index.js +2 -1
- package/plugin/build/codegen/index.js.map +1 -1
- package/plugin/build/codegen/typedTargets.d.ts +11 -1
- package/plugin/build/codegen/typedTargets.d.ts.map +1 -1
- package/plugin/build/codegen/typedTargets.js +102 -12
- package/plugin/build/codegen/typedTargets.js.map +1 -1
- package/plugin/build/config.d.ts +37 -6
- package/plugin/build/config.d.ts.map +1 -1
- package/plugin/build/config.js.map +1 -1
- package/plugin/build/domain/characteristics.d.ts +8 -0
- package/plugin/build/domain/characteristics.d.ts.map +1 -1
- package/plugin/build/domain/characteristics.js +81 -10
- package/plugin/build/domain/characteristics.js.map +1 -1
- package/plugin/build/domain/index.d.ts +1 -1
- package/plugin/build/domain/index.d.ts.map +1 -1
- package/plugin/build/domain/index.js.map +1 -1
- package/plugin/build/ios/apply/podfile/podfile.d.ts.map +1 -1
- package/plugin/build/ios/apply/podfile/podfile.js +21 -4
- package/plugin/build/ios/apply/podfile/podfile.js.map +1 -1
- package/plugin/build/ios/cng/appShortcutsCodegen.d.ts +1 -1
- package/plugin/build/ios/cng/appShortcutsCodegen.d.ts.map +1 -1
- package/plugin/build/ios/cng/appShortcutsCodegen.js +1 -1
- package/plugin/build/ios/cng/appShortcutsCodegen.js.map +1 -1
- package/plugin/build/ios/plan/swiftSources.d.ts.map +1 -1
- package/plugin/build/ios/plan/swiftSources.js +10 -0
- package/plugin/build/ios/plan/swiftSources.js.map +1 -1
- package/plugin/build/ios/plan/types.d.ts +6 -0
- package/plugin/build/ios/plan/types.d.ts.map +1 -1
- package/plugin/build/ios/templates/ReactNativeViewController.swift +45 -7
- package/plugin/build/ios/utils/reactNativeSwift.d.ts +3 -0
- package/plugin/build/ios/utils/reactNativeSwift.d.ts.map +1 -1
- package/plugin/build/ios/utils/reactNativeSwift.js +3 -0
- package/plugin/build/ios/utils/reactNativeSwift.js.map +1 -1
- package/plugin/build/resolveExcludedPackages.d.ts +15 -0
- package/plugin/build/resolveExcludedPackages.d.ts.map +1 -0
- package/plugin/build/resolveExcludedPackages.js +30 -0
- package/plugin/build/resolveExcludedPackages.js.map +1 -0
- package/plugin/build/withTargetsDir.d.ts +5 -0
- package/plugin/build/withTargetsDir.d.ts.map +1 -1
- package/plugin/build/withTargetsDir.js +114 -47
- package/plugin/build/withTargetsDir.js.map +1 -1
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
package expo.modules.targets.extension
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.content.pm.PackageManager
|
|
6
|
+
import android.graphics.Color
|
|
7
|
+
import android.os.Bundle
|
|
8
|
+
import android.util.TypedValue
|
|
9
|
+
import android.view.Gravity
|
|
10
|
+
import android.widget.Button
|
|
11
|
+
import android.widget.LinearLayout
|
|
12
|
+
import android.widget.ScrollView
|
|
13
|
+
import android.widget.TextView
|
|
14
|
+
import org.json.JSONArray
|
|
15
|
+
import org.json.JSONObject
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Base dedicated Activity for share/action targets (Wave 1).
|
|
19
|
+
* Attaches [ExpoTargetsActivityHolder] so JS getSharedData/close/openHostApp work.
|
|
20
|
+
* Native UI is the default; RN hosting is Wave 1 follow-up when USE_RN meta is set
|
|
21
|
+
* (provisional GO — measure TTI before requiring entry on Android).
|
|
22
|
+
*/
|
|
23
|
+
abstract class ExpoTargetsTargetActivity : Activity() {
|
|
24
|
+
protected var targetName: String = "Target"
|
|
25
|
+
protected var appGroup: String = ""
|
|
26
|
+
protected var moduleName: String = "Target"
|
|
27
|
+
protected var useRn: Boolean = false
|
|
28
|
+
|
|
29
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
30
|
+
super.onCreate(savedInstanceState)
|
|
31
|
+
readMeta()
|
|
32
|
+
ExpoTargetsActivityHolder.attach(this)
|
|
33
|
+
setContentView(buildNativeUi())
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override fun onNewIntent(intent: Intent) {
|
|
37
|
+
super.onNewIntent(intent)
|
|
38
|
+
setIntent(intent)
|
|
39
|
+
ExpoTargetsActivityHolder.updateIntent(intent)
|
|
40
|
+
setContentView(buildNativeUi())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override fun onDestroy() {
|
|
44
|
+
ExpoTargetsActivityHolder.detach(this)
|
|
45
|
+
super.onDestroy()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private fun readMeta() {
|
|
49
|
+
try {
|
|
50
|
+
val info =
|
|
51
|
+
packageManager.getActivityInfo(
|
|
52
|
+
componentName,
|
|
53
|
+
PackageManager.GET_META_DATA,
|
|
54
|
+
)
|
|
55
|
+
val meta = info.metaData
|
|
56
|
+
targetName = meta?.getString("expo.targets.TARGET_NAME") ?: targetName
|
|
57
|
+
moduleName = meta?.getString("expo.targets.MODULE_NAME") ?: targetName
|
|
58
|
+
appGroup =
|
|
59
|
+
meta?.getString("expo.targets.APP_GROUP")
|
|
60
|
+
?: "group.$packageName"
|
|
61
|
+
useRn = meta?.getString("expo.targets.USE_RN") == "true"
|
|
62
|
+
} catch (_: Exception) {
|
|
63
|
+
appGroup = "group.$packageName"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private fun dp(value: Float): Int =
|
|
68
|
+
TypedValue.applyDimension(
|
|
69
|
+
TypedValue.COMPLEX_UNIT_DIP,
|
|
70
|
+
value,
|
|
71
|
+
resources.displayMetrics,
|
|
72
|
+
).toInt()
|
|
73
|
+
|
|
74
|
+
private fun buildNativeUi(): ScrollView {
|
|
75
|
+
val pad = dp(20f)
|
|
76
|
+
val gap = dp(10f)
|
|
77
|
+
// Match iOS ShareExtension.tsx accents (#007AFF primary / light chrome).
|
|
78
|
+
val iosBlue = Color.parseColor("#007AFF")
|
|
79
|
+
val labelMuted = Color.parseColor("#666666")
|
|
80
|
+
val cardBg = Color.parseColor("#F2F2F7")
|
|
81
|
+
val titleInk = Color.parseColor("#111111")
|
|
82
|
+
|
|
83
|
+
val column =
|
|
84
|
+
LinearLayout(this).apply {
|
|
85
|
+
orientation = LinearLayout.VERTICAL
|
|
86
|
+
setPadding(pad, pad, pad, pad)
|
|
87
|
+
gravity = Gravity.CENTER_HORIZONTAL
|
|
88
|
+
setBackgroundColor(Color.WHITE)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Eyebrow: map Android Activity → iOS mental model ("Share extension").
|
|
92
|
+
column.addView(
|
|
93
|
+
TextView(this).apply {
|
|
94
|
+
text = parityEyebrow()
|
|
95
|
+
setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
|
|
96
|
+
setTextColor(iosBlue)
|
|
97
|
+
setTypeface(typeface, android.graphics.Typeface.BOLD)
|
|
98
|
+
setPadding(0, 0, 0, dp(4f))
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
column.addView(
|
|
103
|
+
TextView(this).apply {
|
|
104
|
+
text = titleLabel()
|
|
105
|
+
setTextSize(TypedValue.COMPLEX_UNIT_SP, 22f)
|
|
106
|
+
setTextColor(titleInk)
|
|
107
|
+
setTypeface(typeface, android.graphics.Typeface.BOLD)
|
|
108
|
+
setPadding(0, 0, 0, gap)
|
|
109
|
+
},
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
column.addView(
|
|
113
|
+
TextView(this).apply {
|
|
114
|
+
text =
|
|
115
|
+
"Same outcome as an iOS Share extension: this sheet is not the main app.\n" +
|
|
116
|
+
"• Save — write to the app group, then close (does not open the host)\n" +
|
|
117
|
+
"• Open main app — explicit launch of the host (parity with openHostApp)\n" +
|
|
118
|
+
"• Cancel — dismiss without saving"
|
|
119
|
+
setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
|
|
120
|
+
setTextColor(labelMuted)
|
|
121
|
+
setLineSpacing(0f, 1.15f)
|
|
122
|
+
setPadding(0, 0, 0, gap)
|
|
123
|
+
},
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
// Shared payload card — what the user just shared into the extension.
|
|
127
|
+
val payloadCard =
|
|
128
|
+
LinearLayout(this).apply {
|
|
129
|
+
orientation = LinearLayout.VERTICAL
|
|
130
|
+
setPadding(gap, gap, gap, gap)
|
|
131
|
+
background =
|
|
132
|
+
android.graphics.drawable.GradientDrawable().apply {
|
|
133
|
+
setColor(cardBg)
|
|
134
|
+
cornerRadius = dp(10f).toFloat()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
payloadCard.addView(
|
|
138
|
+
TextView(this).apply {
|
|
139
|
+
text = "Shared content"
|
|
140
|
+
setTextSize(TypedValue.COMPLEX_UNIT_SP, 11f)
|
|
141
|
+
setTextColor(labelMuted)
|
|
142
|
+
setTypeface(typeface, android.graphics.Typeface.BOLD)
|
|
143
|
+
setPadding(0, 0, 0, dp(4f))
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
payloadCard.addView(
|
|
147
|
+
TextView(this).apply {
|
|
148
|
+
text = summarizeShared()
|
|
149
|
+
setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
|
|
150
|
+
setTextColor(titleInk)
|
|
151
|
+
},
|
|
152
|
+
)
|
|
153
|
+
payloadCard.addView(
|
|
154
|
+
TextView(this).apply {
|
|
155
|
+
text = "kind:${resolveKindLabel()}"
|
|
156
|
+
setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
|
|
157
|
+
setTextColor(labelMuted)
|
|
158
|
+
setPadding(0, dp(6f), 0, 0)
|
|
159
|
+
},
|
|
160
|
+
)
|
|
161
|
+
column.addView(payloadCard)
|
|
162
|
+
payloadCard.layoutParams =
|
|
163
|
+
LinearLayout.LayoutParams(
|
|
164
|
+
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
165
|
+
LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
166
|
+
).apply { bottomMargin = gap }
|
|
167
|
+
|
|
168
|
+
val saveBtn = primaryButton("Save", iosBlue) { saveAndClose() }
|
|
169
|
+
column.addView(
|
|
170
|
+
saveBtn,
|
|
171
|
+
LinearLayout.LayoutParams(
|
|
172
|
+
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
173
|
+
LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
174
|
+
).apply { bottomMargin = gap },
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
val openBtn = secondaryButton("Open main app", iosBlue) { openHost("/") }
|
|
178
|
+
column.addView(
|
|
179
|
+
openBtn,
|
|
180
|
+
LinearLayout.LayoutParams(
|
|
181
|
+
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
182
|
+
LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
183
|
+
).apply { bottomMargin = gap },
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
column.addView(
|
|
187
|
+
Button(this).apply {
|
|
188
|
+
text = "Cancel"
|
|
189
|
+
setAllCaps(false)
|
|
190
|
+
setTextColor(labelMuted)
|
|
191
|
+
background =
|
|
192
|
+
android.graphics.drawable.GradientDrawable().apply {
|
|
193
|
+
setColor(Color.TRANSPARENT)
|
|
194
|
+
cornerRadius = dp(8f).toFloat()
|
|
195
|
+
}
|
|
196
|
+
setOnClickListener { finish() }
|
|
197
|
+
minimumHeight = dp(44f)
|
|
198
|
+
},
|
|
199
|
+
LinearLayout.LayoutParams(
|
|
200
|
+
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
201
|
+
LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
202
|
+
),
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
return ScrollView(this).apply {
|
|
206
|
+
setBackgroundColor(Color.WHITE)
|
|
207
|
+
addView(column)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private fun roundedFill(
|
|
212
|
+
fill: Int,
|
|
213
|
+
stroke: Int? = null,
|
|
214
|
+
): android.graphics.drawable.GradientDrawable =
|
|
215
|
+
android.graphics.drawable.GradientDrawable().apply {
|
|
216
|
+
setColor(fill)
|
|
217
|
+
cornerRadius = dp(8f).toFloat()
|
|
218
|
+
if (stroke != null) setStroke(dp(1.5f), stroke)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private fun primaryButton(
|
|
222
|
+
label: String,
|
|
223
|
+
accent: Int,
|
|
224
|
+
onClick: () -> Unit,
|
|
225
|
+
): Button =
|
|
226
|
+
Button(this).apply {
|
|
227
|
+
text = label
|
|
228
|
+
setAllCaps(false)
|
|
229
|
+
setTextColor(Color.WHITE)
|
|
230
|
+
background = roundedFill(accent)
|
|
231
|
+
setOnClickListener { onClick() }
|
|
232
|
+
minimumHeight = dp(48f)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
private fun secondaryButton(
|
|
236
|
+
label: String,
|
|
237
|
+
accent: Int,
|
|
238
|
+
onClick: () -> Unit,
|
|
239
|
+
): Button =
|
|
240
|
+
Button(this).apply {
|
|
241
|
+
text = label
|
|
242
|
+
setAllCaps(false)
|
|
243
|
+
setTextColor(accent)
|
|
244
|
+
background = roundedFill(Color.WHITE, accent)
|
|
245
|
+
setOnClickListener { onClick() }
|
|
246
|
+
minimumHeight = dp(48f)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
protected open fun titleLabel(): String = "Share"
|
|
250
|
+
|
|
251
|
+
protected open fun parityEyebrow(): String = "Share extension · Android"
|
|
252
|
+
|
|
253
|
+
private fun resolveKindLabel(): String {
|
|
254
|
+
val data = extractSharedMap() ?: return "text"
|
|
255
|
+
val hasImage = (data["images"] as? List<*>)?.isNotEmpty() == true
|
|
256
|
+
val hasText = data["text"] != null
|
|
257
|
+
val hasUrl = data["url"] != null
|
|
258
|
+
return when {
|
|
259
|
+
hasImage && (hasText || hasUrl) -> "mixed"
|
|
260
|
+
hasImage -> "image"
|
|
261
|
+
hasUrl && !hasText -> "url"
|
|
262
|
+
else -> "text"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private fun summarizeShared(): String {
|
|
267
|
+
val data = extractSharedMap() ?: return "No content"
|
|
268
|
+
val parts = mutableListOf<String>()
|
|
269
|
+
(data["text"] as? String)?.let { parts.add(it) }
|
|
270
|
+
(data["url"] as? String)?.let { parts.add(it) }
|
|
271
|
+
@Suppress("UNCHECKED_CAST")
|
|
272
|
+
val images = data["images"] as? List<String>
|
|
273
|
+
if (images != null && images.isNotEmpty()) {
|
|
274
|
+
parts.add("Images: ${images.size}")
|
|
275
|
+
}
|
|
276
|
+
return parts.joinToString("\n").ifBlank { "No content" }
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private fun extractSharedMap(): Map<String, Any?>? {
|
|
280
|
+
return ExpoTargetsSharedIntent.extract(intent)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private fun saveAndClose() {
|
|
284
|
+
val data = ExpoTargetsSharedIntent.extract(intent) ?: emptyMap()
|
|
285
|
+
val prefs = getSharedPreferences(appGroup, MODE_PRIVATE)
|
|
286
|
+
// Match JS AppGroupStorage namespacing: "{targetName}:items"
|
|
287
|
+
val itemsKey = "$targetName:items"
|
|
288
|
+
val items = JSONArray()
|
|
289
|
+
val existingJson = prefs.getString(itemsKey, null)
|
|
290
|
+
if (existingJson != null) {
|
|
291
|
+
try {
|
|
292
|
+
val prev = JSONArray(existingJson)
|
|
293
|
+
for (i in 0 until prev.length()) {
|
|
294
|
+
items.put(prev.get(i))
|
|
295
|
+
}
|
|
296
|
+
} catch (_: Exception) {
|
|
297
|
+
// start fresh
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
val kind =
|
|
302
|
+
when {
|
|
303
|
+
data["images"] != null && (data["text"] != null || data["url"] != null) -> "mixed"
|
|
304
|
+
data["images"] != null -> "image"
|
|
305
|
+
data["url"] != null && data["text"] == null -> "url"
|
|
306
|
+
else -> "text"
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
val content = JSONObject()
|
|
310
|
+
data["text"]?.let { content.put("text", it) }
|
|
311
|
+
data["url"]?.let { content.put("url", it) }
|
|
312
|
+
@Suppress("UNCHECKED_CAST")
|
|
313
|
+
(data["images"] as? List<String>)?.let { imgs ->
|
|
314
|
+
content.put("images", JSONArray(imgs))
|
|
315
|
+
content.put("imageCount", imgs.size)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
val item =
|
|
319
|
+
JSONObject()
|
|
320
|
+
.put("id", System.currentTimeMillis().toString())
|
|
321
|
+
.put(
|
|
322
|
+
"sharedAt",
|
|
323
|
+
java.text.SimpleDateFormat(
|
|
324
|
+
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
|
325
|
+
java.util.Locale.US,
|
|
326
|
+
).format(java.util.Date()),
|
|
327
|
+
)
|
|
328
|
+
.put("kind", kind)
|
|
329
|
+
.put("content", content)
|
|
330
|
+
items.put(item)
|
|
331
|
+
|
|
332
|
+
prefs.edit().putString(itemsKey, items.toString()).commit()
|
|
333
|
+
|
|
334
|
+
if (intent.action == Intent.ACTION_PROCESS_TEXT) {
|
|
335
|
+
val resultIntent = Intent()
|
|
336
|
+
val original = intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT) ?: ""
|
|
337
|
+
resultIntent.putExtra(Intent.EXTRA_PROCESS_TEXT, original)
|
|
338
|
+
setResult(RESULT_OK, resultIntent)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
finish()
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
private fun openHost(path: String) {
|
|
345
|
+
val launch =
|
|
346
|
+
packageManager.getLaunchIntentForPackage(packageName)
|
|
347
|
+
?: return
|
|
348
|
+
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
349
|
+
launch.putExtra("expo_targets_path", path)
|
|
350
|
+
startActivity(launch)
|
|
351
|
+
finish()
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
open class ExpoTargetsShareActivity : ExpoTargetsTargetActivity() {
|
|
356
|
+
override fun titleLabel(): String = "Share"
|
|
357
|
+
override fun parityEyebrow(): String = "Share extension · Android"
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
open class ExpoTargetsActionActivity : ExpoTargetsTargetActivity() {
|
|
361
|
+
override fun titleLabel(): String = "Action"
|
|
362
|
+
override fun parityEyebrow(): String = "Action extension · Android"
|
|
363
|
+
}
|
package/android/src/main/java/expo/modules/targets/liveActivity/ExpoTargetsLiveActivityModule.kt
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
package expo.modules.targets.liveActivity
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.pm.PackageManager
|
|
5
|
+
import android.os.Build
|
|
6
|
+
import expo.modules.kotlin.modules.Module
|
|
7
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
8
|
+
import expo.modules.targets.notification.ExpoTargetsNotificationRouter
|
|
9
|
+
import org.json.JSONObject
|
|
10
|
+
import java.util.UUID
|
|
11
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Android Live Activity helper (Wave 2): same JS surface as iOS ActivityKit,
|
|
15
|
+
* backed by ongoing NotificationCompat. No Dynamic Island / StandBy / push-to-start.
|
|
16
|
+
*/
|
|
17
|
+
class ExpoTargetsLiveActivityModule : Module() {
|
|
18
|
+
private val activeIds = ConcurrentHashMap<String, String>()
|
|
19
|
+
|
|
20
|
+
override fun definition() = ModuleDefinition {
|
|
21
|
+
Name("ExpoTargetsLiveActivity")
|
|
22
|
+
|
|
23
|
+
AsyncFunction("start") {
|
|
24
|
+
attributesName: String,
|
|
25
|
+
attributesJson: String,
|
|
26
|
+
contentStateJson: String,
|
|
27
|
+
->
|
|
28
|
+
val ctx =
|
|
29
|
+
appContext.reactContext
|
|
30
|
+
?: throw Exception("React context unavailable")
|
|
31
|
+
if (!areEnabled(ctx)) {
|
|
32
|
+
throw Exception("Notifications disabled — cannot start Live Activity helper")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
val activityId = UUID.randomUUID().toString()
|
|
36
|
+
val title = titleFrom(attributesName, attributesJson, contentStateJson)
|
|
37
|
+
val body = bodyFrom(contentStateJson)
|
|
38
|
+
|
|
39
|
+
ExpoTargetsNotificationRouter.presentOngoing(
|
|
40
|
+
ctx,
|
|
41
|
+
activityId,
|
|
42
|
+
title,
|
|
43
|
+
body,
|
|
44
|
+
contentStateJson,
|
|
45
|
+
)
|
|
46
|
+
activeIds[activityId] = attributesName
|
|
47
|
+
persistIds(ctx)
|
|
48
|
+
activityId
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
AsyncFunction("update") { activityId: String, contentStateJson: String ->
|
|
52
|
+
val ctx =
|
|
53
|
+
appContext.reactContext
|
|
54
|
+
?: throw Exception("React context unavailable")
|
|
55
|
+
val attributesName = activeIds[activityId] ?: loadIds(ctx)[activityId]
|
|
56
|
+
if (attributesName == null) return@AsyncFunction false
|
|
57
|
+
|
|
58
|
+
val title = attributesName
|
|
59
|
+
val body = bodyFrom(contentStateJson)
|
|
60
|
+
ExpoTargetsNotificationRouter.presentOngoing(
|
|
61
|
+
ctx,
|
|
62
|
+
activityId,
|
|
63
|
+
title,
|
|
64
|
+
body,
|
|
65
|
+
contentStateJson,
|
|
66
|
+
)
|
|
67
|
+
true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
AsyncFunction("end") { activityId: String ->
|
|
71
|
+
val ctx =
|
|
72
|
+
appContext.reactContext
|
|
73
|
+
?: throw Exception("React context unavailable")
|
|
74
|
+
ExpoTargetsNotificationRouter.cancelOngoing(ctx, activityId)
|
|
75
|
+
activeIds.remove(activityId)
|
|
76
|
+
persistIds(ctx)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
AsyncFunction("endAll") {
|
|
80
|
+
val ctx =
|
|
81
|
+
appContext.reactContext
|
|
82
|
+
?: throw Exception("React context unavailable")
|
|
83
|
+
val ids = (activeIds.keys + loadIds(ctx).keys).toSet()
|
|
84
|
+
ExpoTargetsNotificationRouter.cancelAllLive(ctx, ids)
|
|
85
|
+
activeIds.clear()
|
|
86
|
+
persistIds(ctx)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
AsyncFunction("areActivitiesEnabled") {
|
|
90
|
+
val ctx =
|
|
91
|
+
appContext.reactContext
|
|
92
|
+
?: throw Exception("React context unavailable")
|
|
93
|
+
areEnabled(ctx)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private fun areEnabled(ctx: Context): Boolean {
|
|
98
|
+
if (Build.VERSION.SDK_INT >= 33) {
|
|
99
|
+
val granted =
|
|
100
|
+
ctx.checkSelfPermission(android.Manifest.permission.POST_NOTIFICATIONS) ==
|
|
101
|
+
PackageManager.PERMISSION_GRANTED
|
|
102
|
+
if (!granted) return false
|
|
103
|
+
}
|
|
104
|
+
return ExpoTargetsNotificationRouter.notificationsEnabled(ctx)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private fun titleFrom(
|
|
108
|
+
attributesName: String,
|
|
109
|
+
attributesJson: String,
|
|
110
|
+
contentStateJson: String,
|
|
111
|
+
): String {
|
|
112
|
+
try {
|
|
113
|
+
val attrs = JSONObject(attributesJson)
|
|
114
|
+
val t = attrs.optString("title", "")
|
|
115
|
+
if (t.isNotEmpty()) return t
|
|
116
|
+
} catch (_: Exception) {
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
val state = JSONObject(contentStateJson)
|
|
120
|
+
val t = state.optString("title", "")
|
|
121
|
+
if (t.isNotEmpty()) return t
|
|
122
|
+
} catch (_: Exception) {
|
|
123
|
+
}
|
|
124
|
+
return attributesName
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private fun bodyFrom(contentStateJson: String): String {
|
|
128
|
+
return try {
|
|
129
|
+
val state = JSONObject(contentStateJson)
|
|
130
|
+
state.optString("status", state.toString())
|
|
131
|
+
} catch (_: Exception) {
|
|
132
|
+
contentStateJson
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private fun prefs(ctx: Context) =
|
|
137
|
+
ctx.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
|
138
|
+
|
|
139
|
+
private fun persistIds(ctx: Context) {
|
|
140
|
+
prefs(ctx).edit().putString(KEY_IDS, activeIds.keys.joinToString(",")).commit()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private fun loadIds(ctx: Context): Map<String, String> {
|
|
144
|
+
val raw = prefs(ctx).getString(KEY_IDS, "") ?: ""
|
|
145
|
+
if (raw.isEmpty()) return emptyMap()
|
|
146
|
+
return raw.split(',').filter { it.isNotEmpty() }.associateWith { "live" }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
companion object {
|
|
150
|
+
private const val PREFS = "expo_targets_live_activity"
|
|
151
|
+
private const val KEY_IDS = "active_ids"
|
|
152
|
+
}
|
|
153
|
+
}
|
package/android/src/main/java/expo/modules/targets/notification/ExpoTargetsNotificationModule.kt
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
package expo.modules.targets.notification
|
|
2
|
+
|
|
3
|
+
import android.content.pm.PackageManager
|
|
4
|
+
import android.os.Build
|
|
5
|
+
import expo.modules.kotlin.modules.Module
|
|
6
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
7
|
+
import org.json.JSONArray
|
|
8
|
+
import org.json.JSONObject
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* JS bridge for the Android local notification path (Wave 2).
|
|
12
|
+
* Posts via [ExpoTargetsNotificationRouter] using target config from assets.
|
|
13
|
+
*/
|
|
14
|
+
class ExpoTargetsNotificationModule : Module() {
|
|
15
|
+
override fun definition() = ModuleDefinition {
|
|
16
|
+
Name("ExpoTargetsNotification")
|
|
17
|
+
|
|
18
|
+
AsyncFunction("processAndPresent") {
|
|
19
|
+
title: String,
|
|
20
|
+
body: String,
|
|
21
|
+
targetName: String?,
|
|
22
|
+
->
|
|
23
|
+
val ctx =
|
|
24
|
+
appContext.reactContext
|
|
25
|
+
?: throw Exception("React context unavailable")
|
|
26
|
+
val cfg =
|
|
27
|
+
findTarget(targetName, "notification-service")
|
|
28
|
+
?: throw Exception(
|
|
29
|
+
"No notification-service target in expo_targets_config.json. " +
|
|
30
|
+
"Add platforms:[\"android\"] to a notification-service target.",
|
|
31
|
+
)
|
|
32
|
+
ExpoTargetsNotificationRouter.presentProcessed(
|
|
33
|
+
ctx,
|
|
34
|
+
cfg.appGroup,
|
|
35
|
+
cfg.channelId,
|
|
36
|
+
cfg.channelName,
|
|
37
|
+
title,
|
|
38
|
+
body,
|
|
39
|
+
cfg.mutationMarker,
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
AsyncFunction("presentContent") {
|
|
44
|
+
title: String,
|
|
45
|
+
body: String,
|
|
46
|
+
targetName: String?,
|
|
47
|
+
->
|
|
48
|
+
val ctx =
|
|
49
|
+
appContext.reactContext
|
|
50
|
+
?: throw Exception("React context unavailable")
|
|
51
|
+
val cfg =
|
|
52
|
+
findTarget(targetName, "notification-content")
|
|
53
|
+
?: throw Exception(
|
|
54
|
+
"No notification-content target in expo_targets_config.json. " +
|
|
55
|
+
"Add platforms:[\"android\"] to a notification-content target.",
|
|
56
|
+
)
|
|
57
|
+
ExpoTargetsNotificationRouter.presentRichContent(
|
|
58
|
+
ctx,
|
|
59
|
+
cfg.appGroup,
|
|
60
|
+
cfg.channelId,
|
|
61
|
+
cfg.channelName,
|
|
62
|
+
title,
|
|
63
|
+
body,
|
|
64
|
+
cfg.category,
|
|
65
|
+
)
|
|
66
|
+
true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
AsyncFunction("getLastProcessedTitle") { suite: String ->
|
|
70
|
+
val ctx =
|
|
71
|
+
appContext.reactContext
|
|
72
|
+
?: throw Exception("React context unavailable")
|
|
73
|
+
ExpoTargetsNotificationRouter.readLastTitle(ctx, suite)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
AsyncFunction("areNotificationsEnabled") {
|
|
77
|
+
val ctx =
|
|
78
|
+
appContext.reactContext
|
|
79
|
+
?: throw Exception("React context unavailable")
|
|
80
|
+
if (Build.VERSION.SDK_INT >= 33) {
|
|
81
|
+
val granted =
|
|
82
|
+
ctx.checkSelfPermission(android.Manifest.permission.POST_NOTIFICATIONS) ==
|
|
83
|
+
PackageManager.PERMISSION_GRANTED
|
|
84
|
+
granted && ExpoTargetsNotificationRouter.notificationsEnabled(ctx)
|
|
85
|
+
} else {
|
|
86
|
+
ExpoTargetsNotificationRouter.notificationsEnabled(ctx)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private data class NotifTargetConfig(
|
|
92
|
+
val appGroup: String,
|
|
93
|
+
val channelId: String,
|
|
94
|
+
val channelName: String,
|
|
95
|
+
val category: String,
|
|
96
|
+
val mutationMarker: String,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
private fun findTarget(targetName: String?, type: String): NotifTargetConfig? {
|
|
100
|
+
val ctx = appContext.reactContext ?: return null
|
|
101
|
+
return try {
|
|
102
|
+
val json =
|
|
103
|
+
ctx.assets.open("expo_targets_config.json").bufferedReader().use { it.readText() }
|
|
104
|
+
val arr = JSONArray(json)
|
|
105
|
+
for (i in 0 until arr.length()) {
|
|
106
|
+
val obj = arr.getJSONObject(i)
|
|
107
|
+
if (obj.optString("type") != type) continue
|
|
108
|
+
if (targetName != null && obj.optString("name") != targetName) continue
|
|
109
|
+
val name = obj.optString("name", "Notification")
|
|
110
|
+
val android = obj.optJSONObject("android") ?: JSONObject()
|
|
111
|
+
val packageName = ctx.packageName
|
|
112
|
+
return NotifTargetConfig(
|
|
113
|
+
appGroup =
|
|
114
|
+
obj.optString("appGroup").ifEmpty { "group.$packageName" },
|
|
115
|
+
channelId =
|
|
116
|
+
android.optString("channelId").ifEmpty {
|
|
117
|
+
"expo_targets_${name.lowercase().replace(Regex("[^a-z0-9]"), "")}"
|
|
118
|
+
},
|
|
119
|
+
channelName =
|
|
120
|
+
android.optString("channelName").ifEmpty {
|
|
121
|
+
obj.optString("displayName", name)
|
|
122
|
+
},
|
|
123
|
+
category =
|
|
124
|
+
android.optString("category").ifEmpty { "myNotificationCategory" },
|
|
125
|
+
mutationMarker =
|
|
126
|
+
android.optString("mutationMarker").ifEmpty { " [expo-targets]" },
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
null
|
|
130
|
+
} catch (_: Exception) {
|
|
131
|
+
null
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|