Collecta SDK
要求
- iOS 10.0+
- Xcode 10.2+
- Swift 5+
安装
使用 CocoaPods
CocoaPods 是 Cocoa项目的依赖管理器。有关使用和安装说明,请访问他们的网站。要使用 CocoaPods 将我们的 SDK 集成到 Xcode 项目中,请在 Podfile
中指定它
pod 'CollectaSdk'
然后使用 pod install --repo-update
安装 pods
使用
在您的应用中初始化Collecta SDK
您可以将CollectaSDK初始化代码添加到您的应用程序中,无论是在启动时,还是在应用程序流程中的任何期望点。导入CollectaSdk模块并配置一个共享实例,如下所示:
-
在您的
UIApplicationDelegate
中导入CollectaSdk模块import CollectaSdk
-
在您的应用程序的
application(_:didFinishLaunchingWithOptions:)
方法中配置一个CollectaSdk共享实例CollectaSdk.shared.initialize(username:"your-user-name", password: "your-password", source:"source-1", uuid:"user-id")
参数
username
-> 我们提供的用户名password
-> 我们提供的密码source
-> 我们提供的来源uuid
-> 用户的唯一ID
-
为了响应用户通知的投递,您必须在
application(_:didFinishLaunchingWithOptions:)
中实现共享UNUserNotificationCenter
对象的代理UNUserNotificationCenter.current().delegate = self
-
您的代理对象必须遵守
UNUserNotificationCenterDelegate
协议,并实现userNotificationCenter(_:didReceive:withCompletionHandler:)
和userNotificationCenter(_:willPresent:withCompletionHandler:)
方法。func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { CollectaSdk.shared.userNotificationCenter(didReceive:response) completionHandler() } func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler:@escaping(UNNotificationPresentationOptions)->Void) { completionHandler([.alert,.sound,.badge]) }
发送当前用户位置
您可以在任何想要的时间使用sendLocation(lat:lng)
方法发送当前用户位置,我们建议在您获取用户位置的地方使用这个方法。
func locationManager(_ manager: CLLocationManager,
didUpdateLocations locations: [CLLocation]) {
let location = locations.last!
let lat = location.coordinate.latitude
let lng = location.coordinate.longitude
CollectaSdk.shared.sendLocation(lat:lat, lng:lng)
}
致谢
Collecta SDK 由 MEDRICS Healthcare Solutions Corp 拥有和维护。您可以在 MEDRICS 的领英上关注我们,以获取项目和版本更新。
版权
版权所有 © 2020 MEDRICS Healthcare Solutions Corp。保留所有权利。