每当用户进入/退出区域时通知后端 [英] Notify backend whenever user enters/exits a region

查看:62
本文介绍了每当用户进入/退出区域时通知后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以看来我可以设置100m〜精度的区域并进行监视.每当用户进入/退出区域时,是否可以让设备通知我的后端?即使该应用程序被用户终止,它也能正常工作吗? (假设我始终有权限).

So it seems I can set up regions with 100m~ accuracy and monitor them. Is there a way to have the device notify my backend whenever the user enters/exits a region? And would it work even if the app is terminated by the user? (assuming I have the always permission).

推荐答案

在我的应用程序中,当我进入或退出区域时,就会出现这两个代表.

In my app, these two delegates come when I enter or exit a region.

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

}

func locationManager(manager: CLLocationManager, didExitRegion region: CLRegion){

}

但是请务必按照上述评论所述给予始终授权"

But be sure to give Always Authorization as said in the above comment

override init() {
       super.init()
         if #available(iOS 8.0, *) {
        locationManager.requestAlwaysAuthorization()
    } else {
        // Fallback on earlier versions
    }
    locationManager.startUpdatingLocation()

}

这篇关于每当用户进入/退出区域时通知后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆