jordanbyron / react-native-quick-actions

A react-native interface for Touch 3D home screen quick actions
MIT License
1.06k stars 93 forks source link

EventDeviceEmitter never called/always empty in console.log #76

Closed davidmarinangeli closed 5 years ago

davidmarinangeli commented 5 years ago

Hello, I'm trying to start a screen ( screen2 ) when I press the quickaction. Unfortunately I can't make this work out.

In my screen I declare:

QuickActions.setShortcutItems([ {
    type: "Orders",
    title: "See your orders"
    subtitle: "See orders you've made",
    icon: "Compose",
    userInfo: {
      url: "app://try"
    }
  }
]);

and then, in componentDidMount I call (as you do in your demo):

const subscription = DeviceEventEmitter.addListener(
      'quickActionShortcut', (data) => {this.setState({ eventTtile: data.title })};

    QuickActions.popInitialAction().then((data) => {
      if (data) {
        this.setState({ popAction: data.title });
      }
    }).catch(console.error)

Unfortunately DeviceEventEmitter returns always undefined and the eventTitle is always empty in the state. I tried several things such as move the DeviceEventEmitter in other parts of the component, try to open the app in different ways, unistall and reinstall but nothing works.

jordanbyron commented 5 years ago

Hey Dave,

Do you have a small example app which you can share that reproduces the problem you've described? It sounds like a problem with the way you are using the library, but without a more comprehensive example I can't say for sure.

davidmarinangeli commented 5 years ago

Here's a gist I created from my Component: as you can see from my console, when I cold-launch the app I can see the popInitialAction data but nothing else.

screenshot 2019-01-23 at 13 56 58

https://gist.github.com/davidmarinangeli/d604261f920aca177bb8a536a8b28783

I guess is something related to issue #67 . On XCode I have the same issue

jordanbyron commented 5 years ago

@davidmarinangeli looking at the screen shot of your log the data is being returned as expected. Cold launches will only trigger popInitialAction. Warm launches should hit the DeviceEventEmitter. Also I've found logging the event to be problematic with the timing of when the logger gets attached, that's why the example code you cited from the README uses setState. Unless you think you've found a bug I am going to close this issue as it does not seem like there is actually any problems with this library. If you need help using it in conjunction with other packages I suggest you give stack overflow a try. Thanks!

davidmarinangeli commented 5 years ago

@jordanbyron I've tried also to set the state with the new values but DeviceEventEmitter doesn't work.

The event isn't dispatched, could it be related to #67 ?

aaguiar66934 commented 4 years ago

@jordanbyron I'm having the same issue in which DeviceEventEmmiter is never called in iOS. When the app is closed popoInitialAction() works as expected, but if the app is in background and I click one of the click-actions, the event 'quickActionShortcut' in never triggered. I also think this could be related to #67 .