Search code examples
iosswiftibeacon

How can wake up(or start) my app from background(not running)? ios - ibeacon - iphone


Important: IOS support wake(start) apps when apps not running.

I build a ibeacon app. This is work good . When app is not runnig IOS wake up my app and my app give notification. when app is not runnig, ios run this function (in background) is working

func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {


    var localNotification:UILocalNotification = UILocalNotification()
    localNotification.alertAction = "iBeacon notification."
    localNotification.alertBody = "Detect a signal."
    UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

}

I wanna write a code as "start my app" in this code block ? Like

app.start() or  app.wakeup()

Is it possible?

if(answer == yes){how can i do?}

Solution

  • Unfortunately, this is not possible on iOS. The operating system has restrictions that prevent an app from bringing itself to the foreground unless a user explicitly gestures for it to do so.

    For a demonstration of how this does not work, and the alternatives, please see my similar answer here:

    https://stackoverflow.com/a/22230693/1461050