React-native-navigation: Quick Actions support on iOS (and potentially Android)

Created on 6 Feb 2018  ·  13Comments  ·  Source: wix/react-native-navigation

Issue Description

On iOS there is concept of Quick Actions on the home screen icon - https://developer.apple.com/ios/human-interface-guidelines/extensions/home-screen-actions/

This library already supports 3D Peek and Pop - is there any plans to get Quick Actions support?

There is a React Native library, however looking at this issue (https://github.com/jordanbyron/react-native-quick-actions/issues/47), there are integration issues with Wix Navigation library - most likely the way Wix bootstraps the app compared to standard React Native implementation.


Environment

  • React Native Navigation version: 1.1.297
  • React Native version: 0.47.2
  • Platform(s) (iOS, Android, or both?): Both
  • Device info (Simulator/Device? OS version? Debug/Release?): All
iOS looking for contributors v2

All 13 comments

Can someone look into this please?

@guyca Hey, is this something that's planned?

@Dexwell We don't have plans to support this feature, though we're totally open for contributions.

No problem. react-native-quick-actions works fine with RNN!

@Dexwell Sweet thats awesome! I tried using that library initially (few months ago) but was faced with issues on iOS when the app is not in background i.e. fresh launch from one of the quick actions.

Can you confirm this is working fully on iOS?

This was the issue - https://github.com/jordanbyron/react-native-quick-actions/issues/47

@SukhKalsi I managed to implement quick actions on iOS both from background and fresh launch on the latest RNN 2.0 build :)

Thanks @Dexwell ... good to hear latest v2 of RNN works with the library. I was (still am) using v1... guess that migration may need to happen sooner now!

This issue can be closed. https://github.com/jordanbyron/react-native-quick-actions works perfectly with RNN V2.

@Dexwell Do you care share your workaround. All I get is a black screen

@itsam Just use https://github.com/jordanbyron/react-native-quick-actions with the latest RN and RNN :)

@itsam Just use https://github.com/jordanbyron/react-native-quick-actions with the latest RN and RNN :)

Hi @Dexwell Thank you for your prompt reply. Can you please compare the following with yours and verify the AppDelegate.m file is correct?

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
#import "RNQuickActionManager.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  //performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem
  //completionHandler:(void (^)(BOOL succeeded)) completionHandler
{
  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];

  //[RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler];

  return YES;
}

@end

Please note the comments. If I remove the comments all I get is a black screen (I have no knowledge on objC). With comments on (like the above) it works ONLY for popInitialAction. DeviceEventEmitter cannot listen to "quickActionShortcut". FYI in Android works as expected and I wonder if the fault is on AppDelegate...

Thank you in advance

@itsam You only need to add a new method as instructed in the react-native-quick-actions install instructions. No changes to didFinishLaunchingWithOptions. Try this:

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
#import "RNQuickActionManager.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];

  return YES;
}

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler {
  [RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler];
}

@end

@Dexwell :1st_place_medal: Much appreciated! Thank you, it works now
To whom it may concern, I also realise that you need to embrace your Navigation.push (or overlay or whatever) with Navigation.events().registerAppLaunchedListener.
Do this only on popInitialAction and not on DeviceEventEmitter

Was this page helpful?
0 / 5 - 0 ratings