Commit 9b3f04fa authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

push

parent 47040812
...@@ -90,6 +90,29 @@ ...@@ -90,6 +90,29 @@
return YES; return YES;
} }
- (void)logCollection {
NSMutableDictionary *dict = @{@"event": @"guazinovel", @"action": @"app_start", @"value": @""}.mutableCopy;
[[TQNetworkTools shared] postWithLogCollection:logCollection parameters: dict success:^(__autoreleasing id *response) {
} failure:^(NSError * _Nonnull error) {
}];
}
- (void)initializeIQKeyboardManager{
IQKeyboardManager *keyboardManager = [IQKeyboardManager sharedManager]; // 获取类库的单例变量
keyboardManager.enable = YES; // 控制整个功能是否启用
keyboardManager.shouldResignOnTouchOutside = YES; // 控制点击背景是否收起键盘
keyboardManager.shouldToolbarUsesTextFieldTintColor = YES; // 控制键盘上的工具条文字颜色是否用户自定义
keyboardManager.toolbarManageBehaviour = IQAutoToolbarBySubviews; // 有多个输入框时,可以通过点击Toolbar 上的“前一个”“后一个”按钮来实现移动到不同的输入框
keyboardManager.enableAutoToolbar = NO; // 控制是否显示键盘上的工具条
keyboardManager.shouldShowToolbarPlaceholder = YES; // 是否显示占位文字
keyboardManager.placeholderFont = [UIFont boldSystemFontOfSize:17]; // 设置占位文字的字体
keyboardManager.keyboardDistanceFromTextField = 10.0f; // 输入框距离键盘的距离
}
/** /**
* [ 参考代码,开发者注意根据实际需求自行修改 ] 注册远程通知 * [ 参考代码,开发者注意根据实际需求自行修改 ] 注册远程通知
* *
...@@ -120,26 +143,77 @@ ...@@ -120,26 +143,77 @@
} }
} }
- (void)logCollection { /** 远程通知注册成功委托 */
NSMutableDictionary *dict = @{@"event": @"guazinovel", @"action": @"app_start", @"value": @""}.mutableCopy; - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
//向个推服务器注册deviceToken
[GeTuiSdk registerDeviceTokenData:deviceToken];
//Xcode11打的包,iOS13获取Token有变化
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 13) {
if (![deviceToken isKindOfClass:[NSData class]]) {
//记录获取token失败的描述
return;
}
const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
NSString *strToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
NSLog(@"deviceToken1:%@", strToken);
return;
} else {
NSString *token = [NSString
stringWithFormat:@"%@",deviceToken];
token = [token stringByReplacingOccurrencesOfString:@"<" withString:@""];
token = [token stringByReplacingOccurrencesOfString:@">" withString:@""];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"deviceToken2 is: %@", token);
}
[[TQNetworkTools shared] postWithLogCollection:logCollection parameters: dict success:^(__autoreleasing id *response) { NSLog(@"\n>>>[DeviceToken(NSData)]: %@\n\n", deviceToken);
}
} failure:^(NSError * _Nonnull error) { - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// 将收到的APNs信息传给个推统计
[GeTuiSdk handleRemoteNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
}
}]; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
// iOS 10: App在前台获取到通知
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
NSLog(@"willPresentNotification:%@", notification.request.content.userInfo);
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
// 根据APP需要,判断是否要提示用户Badge、Sound、Alert
completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
} }
- (void)initializeIQKeyboardManager{ // iOS 10: 点击通知进入App时触发,在该方法内统计有效用户点击数
IQKeyboardManager *keyboardManager = [IQKeyboardManager sharedManager]; // 获取类库的单例变量 - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
keyboardManager.enable = YES; // 控制整个功能是否启用
keyboardManager.shouldResignOnTouchOutside = YES; // 控制点击背景是否收起键盘 NSLog(@"didReceiveNotification:%@", response.notification.request.content.userInfo);
keyboardManager.shouldToolbarUsesTextFieldTintColor = YES; // 控制键盘上的工具条文字颜色是否用户自定义
keyboardManager.toolbarManageBehaviour = IQAutoToolbarBySubviews; // 有多个输入框时,可以通过点击Toolbar 上的“前一个”“后一个”按钮来实现移动到不同的输入框 [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
keyboardManager.enableAutoToolbar = NO; // 控制是否显示键盘上的工具条 // [ GTSdk ]:将收到的APNs信息传给个推统计
keyboardManager.shouldShowToolbarPlaceholder = YES; // 是否显示占位文字 [GeTuiSdk handleRemoteNotification:response.notification.request.content.userInfo];
keyboardManager.placeholderFont = [UIFont boldSystemFontOfSize:17]; // 设置占位文字的字体
keyboardManager.keyboardDistanceFromTextField = 10.0f; // 输入框距离键盘的距离 completionHandler();
}
#endif
/** SDK启动成功返回cid */
- (void)GeTuiSdkDidRegisterClient:(NSString *)clientId {
//个推SDK已注册,返回clientId
NSLog(@"\n>>>[GeTuiSdk RegisterClient]:%@\n\n", clientId);
[[TQNetworkTools shared] postWithAction:appPush parameters:@{@"clientId": clientId} success:^(id _Nonnull response) {
NSLog(@"response %@", response);
} failure:^(NSError * _Nonnull error) {
NSLog(@"error %@", error);
}];
} }
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
...@@ -165,6 +239,7 @@ ...@@ -165,6 +239,7 @@
} }
- (void)applicationDidBecomeActive:(UIApplication*)application{ - (void)applicationDidBecomeActive:(UIApplication*)application{
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[[ZJUserInfoManager shared] inviteFriendWithCode]; [[ZJUserInfoManager shared] inviteFriendWithCode];
[[ZJGoodsMagager shared] loadingGoodsUrl:nil]; [[ZJGoodsMagager shared] loadingGoodsUrl:nil];
} }
......
...@@ -94,6 +94,7 @@ typedef enum : NSUInteger { ...@@ -94,6 +94,7 @@ typedef enum : NSUInteger {
iosIPAVerifyReceipt, iosIPAVerifyReceipt,
logCollection, //埋点 logCollection, //埋点
appPush, // 个推
userRemindInfoSet, //上报用户提醒信息 userRemindInfoSet, //上报用户提醒信息
reminderAddRemindType // 添加提醒类型 reminderAddRemindType // 添加提醒类型
......
...@@ -403,6 +403,8 @@ static TQNetworkTools* _tools = nil; ...@@ -403,6 +403,8 @@ static TQNetworkTools* _tools = nil;
return @"/app/v1/location/pay/ios-verify-receipt"; return @"/app/v1/location/pay/ios-verify-receipt";
case logCollection: case logCollection:
return @"/logCollection/log/v1/userLogCollection"; return @"/logCollection/log/v1/userLogCollection";
case appPush:
return @"/app/v1/init-push";
case userRemindInfoSet: case userRemindInfoSet:
return @"/app/v1/location/remind/remind"; return @"/app/v1/location/remind/remind";
case reminderAddRemindType: case reminderAddRemindType:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment