Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide option to not blindly foreground app's lastWindow from deepLinks #1355

Conversation

christophpurrer
Copy link

@christophpurrer christophpurrer commented Aug 11, 2022

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

Messenger Desktop is a multi-window application (chat, calling, settings, …) and we maintain the various windows with a windowNativeModule which allows JS interaction.

When receiving deep-links from other apps we don’t want to necessary re-open the lastWindow open as the deep-link might contain information about a particular scenario (open login page, start a call). Hence, we need to disable this behavior app wide and use our windowNativeModule to foreground the specific window related to the deep link.

  • This change has 0 effect on other apps
  • We could make this property an ivar, but then we need to manually register RCTLinkingManager.mm in ReactBridgeFactory-macOS.mm ….
  • We could append a special url property to deep-links, but I think that would make the ‘API’ harder to use`

To use this 'feature' you would add this line in AppDelegate

  [RCTLinkingManager setAlwaysForegroundLastWindow:NO]; // <- Add this
  [[NSAppleEventManager sharedAppleEventManager] setEventHandler:[RCTLinkingManager class]
                                                     andSelector:@selector(getUrlEventHandler:withReplyEvent:)
                                                   forEventClass:kInternetEventClass

Changelog

[macOS] [Added] - Provide option to not blindly foreground app's lastWindow from deepLinks

Test Plan

Using js/examples/Linking/LinkingExample.js I simply added an eventListener

Linking.addEventListener('url', url => console.log(url));

as otherwise the LinkingManager.mm does not observe:
https://github.com/microsoft/react-native-macos/blob/main/Libraries/LinkingIOS/macos/RCTLinkingManager.mm#L44

https://github.com/microsoft/react-native-macos/blob/main/React/Modules/RCTEventEmitter.m#L115

Disable alwaysForegroundLastWindow

dontF.mov

Current behavior, always foreground

Fore.mov

Messenger Desktop is a multi-window application (chat, calling, settings, …) and we maintain the various windows with a windowNativeModule which allows JS interaction.

When receiving deep-links from other apps we don’t want to necessary re-open the lastWindow open as the deep-link might contain information about a particular scenario (open login page, start a call). Hence, we need to disable this behavior app wide and use our windowNativeModule to forward the specific window related to the deep link.

- This change has 0 effect on other apps
- We could make this property an ivar, but then we need to manually register RCTLinkingManager.mm ….
- We could append a special url property to deep-links, but I think that would make the ‘API’ harder to use`
@Saadnajmi Saadnajmi merged commit 5596c26 into microsoft:main Aug 23, 2022
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
…nks (microsoft#1355)

Messenger Desktop is a multi-window application (chat, calling, settings, …) and we maintain the various windows with a windowNativeModule which allows JS interaction.

When receiving deep-links from other apps we don’t want to necessary re-open the lastWindow open as the deep-link might contain information about a particular scenario (open login page, start a call). Hence, we need to disable this behavior app wide and use our windowNativeModule to forward the specific window related to the deep link.

- This change has 0 effect on other apps
- We could make this property an ivar, but then we need to manually register RCTLinkingManager.mm ….
- We could append a special url property to deep-links, but I think that would make the ‘API’ harder to use`
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Mar 10, 2023
…nks (microsoft#1355)

Messenger Desktop is a multi-window application (chat, calling, settings, …) and we maintain the various windows with a windowNativeModule which allows JS interaction.

When receiving deep-links from other apps we don’t want to necessary re-open the lastWindow open as the deep-link might contain information about a particular scenario (open login page, start a call). Hence, we need to disable this behavior app wide and use our windowNativeModule to forward the specific window related to the deep link.

- This change has 0 effect on other apps
- We could make this property an ivar, but then we need to manually register RCTLinkingManager.mm ….
- We could append a special url property to deep-links, but I think that would make the ‘API’ harder to use`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants