NeosuranceSDK
- 从设备传感器和托管应用程序中收集信息
- 与人工智能引擎交换信息
- 发送推送通知
- 显示着陆页面
- 显示已购买政策的列表
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
需求
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationAlwaysUsageDescription</key>
<string>Always...</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>When in use...</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Always and when in use...</string>
<key>NSMotionUsageDescription</key>
<string>Motion...</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>fetch</string>
<string>location</string>
<string>remote-notification</string>
</array>
安装
NeosuranceSDK 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
pod 'NeosuranceSDK'
- 初始化
NSMutableDictionary* settings = [[NSMutableDictionary alloc] init];
[settings setObject:@"https://sandbox.neosurancecloud.net/sdk/api/v1.0/" forKey:@"base_url"];
[settings setObject:@"xxxx" forKey:@"code"];
[settings setObject:@"xxxx" forKey:@"secret_key"];
[[NeosuranceSDK sharedInstance] setupWithDictionary:settings];
[[NeosuranceSDK sharedInstance] stayInBackground];
- 设置用户
NSRUser* user = [[NSRUser alloc] init];
user.email = @"[email protected]";
user.code = @"[email protected]";
user.firstname = @"Jhon";
user.lastname = @"Doe";
[[NeosuranceSDK sharedInstance] registerUser:user];
- -(BOOL)转发通知
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
if(![[NeosuranceSDK sharedInstance] forwardNotification:response withCompletionHandler:(void(^)(void))completionHandler]) {
//TODO: handle your notification
}
completionHandler();
}
- -(void)显示应用
[[NeosuranceSDK sharedInstance] showApp];
- -(void)自定义事件:(NSDictionary*)
NSMutableDictionary* payload = [[NSMutableDictionary alloc] init];
[payload setObject:@"custom" forKey:@"type"];
[[NeosuranceSDK sharedInstance] sendEvent:@"custom" payload:payload];
- -(void)设置安全代理:(NSRSecurityDelegate*)
@protocol NSRSecurityDelegate <NSObject>
-(void)secureRequest:(NSString* _Nullable)endpoint payload:(NSDictionary* _Nullable)payload headers:(NSDictionary* _Nullable)headers completionHandler:(void (^)(NSDictionary* responseObject, NSError *error))completionHandler;
@end
[[NeosuranceSDK sharedInstance] setSecurityDelegate:[[MySecurityDelegate alloc] init]];
作者
许可证
NeosuranceSDK 在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。