react-native-webrtc / react-native-webrtc/react-native-incall-manager

Proximity sensor event not being fired

Open
#94 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
597
Forks
201
Avg merge
2h 42m
Merged PRs (30d)
1

Description

Hi,

I recently starting using this library with a project created with react native init. I manually linked the library per the instructions.

I noticed the proximity sensor functionality was not working as expected. After calling InCallManager.start(), the screen would not turn off when something was close to the sensor.

I checked the code in RNInCallManager.m and found the function for starting the proximity sensor, and noticed _currentDevice.proximityMonitoringEnabled set to NO:

- (void)startProximitySensor
{
    if (_isProximityRegistered) {
        return;
    }

    NSLog(@"RNInCallManager.startProximitySensor()");
    // _currentDevice.proximityMonitoringEnabled = YES;
    _currentDevice.proximityMonitoringEnabled = NO;
    
    // --- in case it didn't deallocate when ViewDidUnload
    [self stopObserve:_proximityObserver
                 name:UIDeviceProximityStateDidChangeNotification
               object:nil];

    _proximityObserver = [self startObserve:UIDeviceProximityStateDidChangeNotification
                                     object:_currentDevice
                                      queue: nil
                                      block:^(NSNotification *notification) {
        BOOL state = _currentDevice.proximityState;
        if (state != _proximityIsNear) {
            NSLog(@"RNInCallManager.UIDeviceProximityStateDidChangeNotification(): isNear: %@", state ? @"YES" : @"NO");
            _proximityIsNear = state;
            [self sendEventWithName:@"Proximity" body:@{@"isNear": state ? @YES : @NO}];
        }
    }];

    _isProximityRegistered = YES;
}

I uncommented the line setting it to YES and commented the line setting it to NO, and it starting working after rebuilding. However it now gives this warning:

-[UIApplication setExpectsFaceContact:inLandscape:] must be used from main thread only

I'm wondering if this is the actual fix or if I am missing something. Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in RNInCallManager.m at startProximitySensor and compare the proximityMonitoringEnabled settings described in the report. Reproduce the behavior after rebuilding the manually linked library, then verify that the proximity event fires without the reported main-thread warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.