junny_location_punch 1.2.2
junny_location_punch: ^1.2.2 copied to clipboard
A Flutter package for location-based attendance tracking and punch-in management system.
Features #
这是为项目抽取的定位打卡功能库。 目前定位功能使用高德
Getting started #
Android #
android/src/main/AndroidManifest.xml添加以下内容 具体参考example
<manifest>
<application>
/// 需要配置的
<meta-data android:name="com.amap.api.v2.apikey" android:value="您的Key" />
</application>
</manifest>
iOS #
- 在info.plist中增加:
<key>NSLocationWhenInUseUsageDescription</key>
<string>要用定位</string>
如果ios定位没有返回逆地理信息,添加一下内容
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsForMedia</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
/// 解决ios HTTP 警告,需要添加的
<key>NSExceptionDomains</key>
<dict>
<key>restios.amap.com/key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
</dict>
</dict>
- iOS 9及以上版本使用后台定位功能, 需要保证"Background Modes"中的"Location updates"处于选中状态
3.使用地理围栏
iOS14及以上版本使用地理围栏功能,需要在plist中配置NSLocationTemporaryUsageDescriptionDictionary字典描述, 且添加自定义Key描述地理围栏的使用场景,此描述会在申请临时精确定位权限的弹窗中展示。 该回调触发条件:拥有定位权限,但是没有获得精确定位权限的情况下,会触发该回调。此方法实现调用申请临时精确定位权限API即可;
** 需要注意,在iOS9及之后版本的系统中,如果您希望程序在后台持续检测围栏触发行为,需要保证manager的 allowsBackgroundLocationUpdates 为 YES, 设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。