Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

iOS - Item press not working when app is in background #96

Open
aaguiar66934 opened this issue Mar 9, 2020 · 5 comments
Open

iOS - Item press not working when app is in background #96

aaguiar66934 opened this issue Mar 9, 2020 · 5 comments

Comments

@aaguiar66934
Copy link

In iOS (tested in 13.3.1) when the app is in background, the item press is not working. It seems that the event "quickActionShortcut" is never triggered. My react-native code is as you recommend in the documentation:

DeviceEventEmitter.addListener("quickActionShortcut", data => {
  console.log(data);
});

"react": "16.9.0",
"react-native": "0.61.2",
"react-native-quick-actions": "0.3.13"

@joaodematejr
Copy link

+1

@GodsEye-07
Copy link

Same in Android as well.

@shukerullah
Copy link

For me listener was working fine but it was triggered before navigator was initialized. I added setTimeout as you can see in following snippet:

function quickAction(data) {
  if (data && data.userInfo && data.userInfo.url) {
    setTimeout(() => {
      LinkRoutes(data.userInfo.url);
    }, TIME);
  }
}

@pmcamacho
Copy link

pmcamacho commented Dec 19, 2022

Hey! All good?

Indeed. I was trying this library and this also does not work on ios when the app is in background for me.
Does anyone found a workaround?
Are there plans to make it work?

The following callback does not get triggered when ios app is on background
DeviceEventEmitter.addListener("quickActionShortcut", data => { console.log(data); });

I am using:
"react": "18.1.0", "react-native": "0.70.1", "react-native-quick-actions": "^0.3.13",

and tested it in simulator and iphone 13 with ios 15 and 16.

Thanks in advance!

@pmcamacho
Copy link

pmcamacho commented Dec 19, 2022

I figured out the problem I was having! It works now also for ios both closed or in background app state.

So in the AppDelegate.m file you need to add as stated in the docs
#import "RNQuickActionManager.h"
and also
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler { [RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler]; }

But careful do not put the import or the code inside an @ if (with no space between @ and if) in the code.

So in my case the code I added it right before the last @ end (with no space between @ and end) and the import right on top near the other ones.

So basically I was adding them inside @ if (with no space between @ and if) and so I guess the code was not loaded and run in my case so I was not able to make it work and it was failing silently.

Hope it helps someone!

Happy coding!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants