react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Quick Actions support on iOS (and potentially Android)

Open SukhKalsi opened this issue 8 years ago • 13 comments

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

SukhKalsi avatar Feb 06 '18 09:02 SukhKalsi

Can someone look into this please?

SukhKalsi avatar Jun 12 '18 12:06 SukhKalsi

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

doneydenouden avatar Jul 26 '18 12:07 doneydenouden

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

guyca avatar Jul 26 '18 12:07 guyca

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

doneydenouden avatar Jul 30 '18 18:07 doneydenouden

@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 avatar Jul 31 '18 14:07 SukhKalsi

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

doneydenouden avatar Jul 31 '18 14:07 doneydenouden

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!

SukhKalsi avatar Aug 01 '18 09:08 SukhKalsi

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

ItsNoHax avatar Jan 08 '19 12:01 ItsNoHax

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

itsam avatar May 19 '19 07:05 itsam

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

doneydenouden avatar May 20 '19 13:05 doneydenouden

@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 avatar May 20 '19 15:05 itsam

@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

doneydenouden avatar May 21 '19 08:05 doneydenouden

@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

itsam avatar May 21 '19 10:05 itsam