0

I'm learning app development, both in IOS and Android, and after searching I'm not sure if I got my answer: I want to build an app that basicaly alerts the user when other user (same app) is nearby. The alert comes if they have, like, common interests (previously the users fill some kind of form). I found this piece of code here in Stack Overflow, but i'm not sure if it does this kind of job. Can anyone give me some hint?

- (void) activateProximitySensor {
UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled = YES;
if (device.proximityMonitoringEnabled == YES) {
    [[NSNotificationCenter defaultCenter] addObserver:self    selector:@selector(proximityChanged:)   name:@"UIDeviceProximityStateDidChangeNotification" object:device];
     }
    }

   - (void) proximityChanged:(NSNotification *)notification {
    UIDevice *device = [notification object];
    NSLog(@"Detectat");

     //DO WHATEVER I WANT
    }
glassraven
  • 323
  • 2
  • 13

1 Answers1

0

Proximity monitoring in this context is related to the sensor which detects light levels (on iPhone's found just above the front-facing speaker), this is used to determine when the phone is held against the persons ear or changing screen brightness dependant upon light levels.

This answer may be of interest to you, How to detect nearby devices with Bluetooth LE in iOS 7.1 both in background and foreground?.

Otherwise you would need to track the device's GPS co-ordinates and broadcast these to other clients.

Community
  • 1
  • 1
Leon Storey
  • 3,274
  • 2
  • 25
  • 40
  • The normal approach for the OP's case would be to enable location monitoring for significant location changes, update a server in the background, and have that server search for other clients nearby (in space and time) sending APNS to those that qualify. – danh Dec 12 '16 at 20:20