IOS: Available actions after iBeacon detection

203 views Asked by At

If a locked iPhone detects an iBeacon signal registered with my app, can my app, during its ~5-10sec wake up time:

  1. contact my web server to send some data?
  2. send a predefined text message?
  3. access the iPhone's current GPS location?
2

There are 2 answers

2
davidgyoung On BEST ANSWER

Yes, I can confirm you can contact a web server, and access fine location (GPS) as I commonly do this during the window you mention.

I have less experience sending SMS text messages on iOS, but my basic understanding is that you cannot send SMS messages at all in an automated fashion on iOS, you can only present the screen to the user to initiate the send. I do not believe you can do this when your app is not in the foreground.

You can, however, send local notifications that appear on the lock screen.

0
nilam_mande On

Yes app can do all these actions while phone is locked.

Also if you want to continue scanning and all these functionalities in the background you can use UIBackgroundTaskIdentifier

It will continue scanning in the background till there is any beacon detected. Once there will be no beacon available, it stops scanning in background at the end of tolerate time.

- (void)applicationDidEnterBackground:(UIApplication *)application
 {
   NSLog(@"=== DID ENTER BACKGROUND ===");
   UIBackgroundTaskIdentifier bgTask = [[UIApplication  sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
         NSLog(@"End of tolerate time. Application should be suspended now if we do not ask more 'tolerance'");
       }];

  if (bgTask == UIBackgroundTaskInvalid) {
      NSLog(@"This application does not support background mode");
  }
  else {
     //if application supports background mode, we'll see this log.
     NSLog(@"Application will continue to run in background");
  }
}