You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linking.sendIntent() currently only runs Intents with actions. This is a limitation, and prevents intents that require a URI link too. IE
ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION added in API 30 docs
My hope is to add support for URI links, so they are added to the intent. This will fix menu issues where a app uri needs to be provided.
Example native code that would navigate the user to the
val uri:Uri=Uri.parse("package:"+"com.exampleApp")
val fileManagerIntent =Intent("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION", uri)
startActivity(reactApplicationContext, fileManagerIntent, null)
This would make the Intent use the constructor here
I propose adding additional params to the Linking.sendIntent.
This would require a breaking change to be mentioned for react-native dependencies if we changed the order of params.
It would fix any global permissions navigation issues such as file access intents and allow android to trigger custom intents for other apps.
Proposed changes (please interject if this seems wrong).
Noting that these are not the react-native codebase files but the provided node_module files that I patch-packaged. This fix will not work unless you re-compile the react-native 0.71.4 library with the changes below.
diff --git a/node_modules/react-native/Libraries/Linking/Linking.d.ts b/node_modules/react-native/Libraries/Linking/Linking.d.ts
index 36dbe9f..1ef3b92 100644
--- a/node_modules/react-native/Libraries/Linking/Linking.d.ts+++ b/node_modules/react-native/Libraries/Linking/Linking.d.ts@@ -53,6 +53,7 @@ export interface LinkingStatic extends NativeEventEmitter {
*/
sendIntent(
action: string,
+ url: string,
extras?: Array<{key: string; value: string | number | boolean}>,
): Promise<void>;
}
diff --git a/node_modules/react-native/Libraries/Linking/Linking.js b/node_modules/react-native/Libraries/Linking/Linking.js
index a59fa72..952e760 100644
--- a/node_modules/react-native/Libraries/Linking/Linking.js+++ b/node_modules/react-native/Libraries/Linking/Linking.js@@ -111,6 +111,7 @@ class Linking extends NativeEventEmitter<LinkingEventDefinitions> {
*/
sendIntent(
action: string,
+ url: string = null,
extras?: Array<{
key: string,
value: string | number | boolean,
@@ -118,7 +119,7 @@ class Linking extends NativeEventEmitter<LinkingEventDefinitions> {
}>,
): Promise<void> {
if (Platform.OS === 'android') {
- return nullthrows(NativeIntentAndroid).sendIntent(action, extras);+ return nullthrows(NativeIntentAndroid).sendIntent(action, url, extras);
} else {
return new Promise((resolve, reject) => reject(new Error('Unsupported')));
}
diff --git a/node_modules/react-native/Libraries/Linking/NativeIntentAndroid.js b/node_modules/react-native/Libraries/Linking/NativeIntentAndroid.js
index 7a9f9b7..dd731c5 100644
--- a/node_modules/react-native/Libraries/Linking/NativeIntentAndroid.js+++ b/node_modules/react-native/Libraries/Linking/NativeIntentAndroid.js@@ -19,6 +19,7 @@ export interface Spec extends TurboModule {
+openSettings: () => Promise<void>;
+sendIntent: (
action: string,
+ url: ?string,
extras: ?Array<{
key: string,
value: string | number | boolean, // TODO(T67672788): Union types are not type safe
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java
index 7b532d4..d27eac4 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java@@ -167,13 +167,19 @@ public class IntentModule extends NativeIntentAndroidSpec {
* @param extras An array of extras [{ String, String | Number | Boolean }]
*/
@Override
- public void sendIntent(String action, @Nullable ReadableArray extras, Promise promise) {+ public void sendIntent(String action, @Nullable String url, @Nullable ReadableArray extras, Promise promise) {
if (action == null || action.isEmpty()) {
promise.reject(new JSApplicationIllegalArgumentException("Invalid Action: " + action + "."));
return;
}
- Intent intent = new Intent(action);+ Intent intent++ if (url != null){+ intent = new Intent(action, url)+ } else {+ intent = new Intent(action)+ }
PackageManager packageManager = getReactApplicationContext().getPackageManager();
if (intent.resolveActivity(packageManager) == null) {
Example:
const uri = "package:com.exampleApp"
Linking.sendIntent(
'android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION',
uri,
)
Discussion points
Support intents that require app context.
Determine how the refactor should be done (IE breaking change or some other option)
Alternative solutions
Extend openSettings and allow uri there since this issue is related to the android settings action being fired but not being able to navigate to the screen without a package uri.
Install react-native-send-intent with my fork branch changes. (It adds the linking fix only to openSettings(). IE yarn add https://github.com/FrederickEngelhardt/react-native-send-intent/\#feat/add-open-settings-uri-context
The extra key does not allow the app to navigate to the file permission manager under settings.
The text was updated successfully, but these errors were encountered:
FrederickEngelhardt
changed the title
Make Linking.getIntent support Intent(action,uri)
Make Linking.sendIntent support Intent(action,uri)
Mar 27, 2023
Introduction
Linking.sendIntent()
currently only runs Intents with actions. This is a limitation, and prevents intents that require a URI link too. IEACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
added in API 30 docsMy hope is to add support for URI links, so they are added to the intent. This will fix menu issues where a app uri needs to be provided.
Example native code that would navigate the user to the
This would make the Intent use the constructor here
Details
I propose adding additional params to the
Linking.sendIntent
.Proposed changes (please interject if this seems wrong).
Noting that these are not the react-native codebase files but the provided node_module files that I patch-packaged. This fix will not work unless you re-compile the react-native 0.71.4 library with the changes below.
Example:
Discussion points
Alternative solutions
uri
there since this issue is related to the android settings action being fired but not being able to navigate to the screen without a package uri.yarn add https://github.com/FrederickEngelhardt/react-native-send-intent/\#feat/add-open-settings-uri-context
Workarounds?
Tried the following:
The extra key does not allow the app to navigate to the file permission manager under settings.
The text was updated successfully, but these errors were encountered: