123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- //
- // SKTabbarViewController+function.m
- // Overseas Watch
- //
- // Created by 刘振兴 on 2023/12/19.
- // Copyright © 2023 BaH Cy. All rights reserved.
- //
- #import "SKTabbarViewController+function.h"
- #import "IanAdsStartView.h"
- #import "SKWebViewViewController.h"
- @interface SKTabbarViewController ()<DataManagerDelegate>
- @end
- @implementation SKTabbarViewController (function)
- - (void)initDataManager:(NSArray*)controllers {
- for (id v in controllers) {
- [[DataManager shared] addDelegate:v];
- }
- [[DataManager shared] firstReloadChildsDevices];
- }
- - (void)initFunction {
- //开屏广告请求
- //[self requestLaunchAdsImage];
-
- //推送历史
- //[self requestPushRecord];
-
- [[VideoManager shared] initJuphoon];
-
- [[DataManager shared] requestSession:^(BOOL isOK) {
- }];
- [[SKWebSocket share] initSocket];
-
- [self refreshPushToken];
- }
- - (void)initObserver {
- [EUtil addInformation:self name:@"SK_TOKEN_EXPIRED" sel:kSEL(showOtherPlaceLogin)];
- [EUtil addInformation:self name:@"onRefreshPushToken" sel:kSEL(refreshPushToken)];
- }
- - (void)onBindAlready {
- [self initFunction];
- }
- - (void)onReceiveNewChat {
- if (self.isSkip)
- return;
- self.isSkip = YES;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- self.isSkip = NO;
- [[DataManager shared] requestSession:^(BOOL isOK) {
- }];
- });
- }
- - (void)onRefreshTabBarBadge:(NSInteger)count {
- UITabBarItem* item = [self.tabBar.items objectAtIndex:1];
- if (count <= 0)
- [item setBadgeValue:nil];
- else {
- [item setBadgeValue:[NSString stringWithFormat:@"%ld", count]];
- }
- }
- - (void)onSocketStatusChange {
- BOOL status = [[SKWebSocket share] isConnected];
- if (status == 1) {
- [self onRefreshTabBarBadge:0];
- }
- }
- - (void)refreshPushToken {
- [[DataManager shared] requestPushToken:^(BOOL isOK) {
- HDNormalLog(([NSString stringWithFormat:@"PUSH TOKEN isOK: ? : %d", isOK]));
- }];
- }
- - (void)showOtherPlaceLogin {
- //@"您的账号在异地登陆,如非本人操作,请及时更换密码。"
- if (self.mOtherPlaceLoginAlert == nil) {
- self.mOtherPlaceLoginAlert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Other.Place.Login.Title", nil) message:NSLocalizedString(@"Other.Place.Login.Mes", nil) preferredStyle:UIAlertControllerStyleAlert];
- [self.mOtherPlaceLoginAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Confirm", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- self.mOtherPlaceLoginAlert = nil;
- }]];
- [self presentViewController:self.mOtherPlaceLoginAlert animated:YES completion:nil];
- }
-
- [[DataManager shared] clearPushToken:^(BOOL isOK) {
- }];
- [[DataManager shared] logout];
- }
- - (void)reciveKidoMessage:(NSNotification*)notification {
- NSMutableDictionary* dic = (NSMutableDictionary*)notification.object;
-
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Push.Message.Title", nil) message:dic[@"Title"] preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- }]];
- [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Detail", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- NSString* url = dic[@"url"];
- if (url != nil && ![url isEqualToString:@""]) {
- NSString *title = dic[@"Title"];
- SKWebViewViewController *webVc = [[self storyboard] instantiateViewControllerWithIdentifier:@"WebViewVC"];
- webVc.title = title;
- webVc.urlToOpen = url;
- webVc.mIsShare = YES;
- webVc.mIsOpenApp = YES;
- webVc.mType = [dic[@"type"] integerValue]; //应该是16,富文本
- webVc.mId = [dic[@"Id"] integerValue];
- [self presentViewController:webVc animated:YES completion:nil];
- }
- }]];
- [self presentViewController:alert animated:YES completion:nil];
- }
- #pragma mark - LaunchAds
- - (void)requestLaunchAdsImage {
- NSDictionary *param = @{ };
- [ERequest httpRequest:param httpURL:@"" httpMethod:@"POST" onSuccess:^(NSDictionary *result) {
- if ([ERequest isSuccessWithResult:result]) {
-
- NSDictionary* dic = result[@"data"];
- NSString* url = dic[@"ImageUrl"];
- if ([url isKindOfClass:[NSNull class]] || url == nil)
- return;
-
- NSString* temp = [EUtil parseDictionary2String:dic];
- [[NSUserDefaults standardUserDefaults] setValue:temp forKey:@"Key_LaunchAds"];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- if (![url isEqualToString:@""])
- [IanAdsStartView downloadStartImage:url];
- }else{
- }
- } onFailure:^(NSError *error) {
- }];
- }
- - (void)requestPushRecord {
- NSDictionary *param = @{ };
- [ERequest httpRequest:param httpURL:URL_PUSH_MESSAGE httpMethod:@"POST" onSuccess:^(NSDictionary *result){
- if([ERequest isSuccessWithResult:result]) {
- NSArray *retList = result[@"data"];
- [[DataManager shared].mPushRecordArray removeAllObjects];
- [DataManager shared].mPushRecordArray = [NSMutableArray arrayWithArray:retList];
- }
- }onFailure:^(NSError *error) {
- }];
- }
- @end
|