Search code examples
iosobjective-creactjsreact-nativeplivo

Receiving React Native events while app is in sleep mode


I'm trying to add a Native Module to my React Native project but I'm having difficulties receiving JS events when my phone is in sleep mode.

I've implemented event dispatchers as stated in the documentation here: https://facebook.github.io/react-native/docs/native-modules-ios.html#sending-events-to-javascript

And here is the specific code:

- (void)onIncomingCall:(PlivoIncoming*)incoming
{
    incall = incoming;
    [self.bridge.eventDispatcher
     sendAppEventWithName:@"onIncomingCall"
     body:nil];
}

This works fine when my app is in foreground and background.

Is there anyway to solve this?

EDIT Seems as though onIncomingCall is not triggered while in sleep mode. Any ideas why this might happen?


Solution

  • The answer to this question is that delegates work in background mode but not in inactive mode which sets in when the app/phone as been idle for > 15 mins.

    Solution to this problem was to add a VOIP push to wake up the app so that delegates can be handled again.