小说绘上架版本
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// AppDelegate+TFAISpeech.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFAISpeech)
|
||||
|
||||
- (void)initAISpeech;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// AppDelegate+TFAISpeech.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFAISpeech.h"
|
||||
#if TF_Enable_Ai
|
||||
#import "iflyMSC/IFlyMSC.h"
|
||||
#endif
|
||||
|
||||
@implementation AppDelegate (TFAISpeech)
|
||||
|
||||
- (void)initAISpeech
|
||||
{
|
||||
#if TF_Enable_Ai
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
NSString *initString = [[NSString alloc] initWithFormat:@"appid=%@", IFLY_App_ID];
|
||||
[IFlySpeechUtility createUtility:initString];
|
||||
[IFlySetting showLogcat:NO];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// AppDelegate+TFAdvertising.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#if TF_Enable_Third_Party_Ad
|
||||
#import <BUAdSDK/BUAdSDK.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFAdvertising)
|
||||
#if TF_Enable_Third_Party_Ad
|
||||
<BUSplashAdDelegate>
|
||||
#endif
|
||||
|
||||
- (void)initLaunchADView;
|
||||
|
||||
- (void)initADManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// AppDelegate+TFAdvertising.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFAdvertising.h"
|
||||
#import "AppDelegate+TFStartTimes.h"
|
||||
#import "XHLaunchAd.h"
|
||||
#import "TFWebViewController.h"
|
||||
#import "TFAudioDetailViewController.h"
|
||||
|
||||
@implementation AppDelegate (TFAdvertising)
|
||||
|
||||
- (void)initADManager
|
||||
{
|
||||
#if TF_Enable_Third_Party_Ad
|
||||
|
||||
if (BUA_App_Key.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
[BUAdSDKManager setAppID:BUA_App_Key];
|
||||
[BUAdSDKManager setIsPaidApp:NO];
|
||||
[BUAdSDKManager setLoglevel:BUAdSDKLogLevelError];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)initLaunchADView
|
||||
{
|
||||
#if TF_Launch_Advertising
|
||||
// 如果启动引导页将不加载广告启动图
|
||||
if ([self startTimes] == 1) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:TF_START_PAGE];
|
||||
|
||||
StartPage *start_page = [StartPage modelWithJSON:data];
|
||||
|
||||
if (start_page.skip_type == 5) { // 穿山甲开屏广告
|
||||
|
||||
} else { // 自带开屏广告
|
||||
[self createXLLaunchAdView:start_page];
|
||||
}
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(7.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{// 设置固定时间强制显示状态栏
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)createXLLaunchAdView:(StartPage *)start_page
|
||||
{
|
||||
if (!start_page.image || start_page.image.length <= 0) {
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
return;
|
||||
}
|
||||
|
||||
[XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
|
||||
XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
|
||||
imageAdconfiguration.duration = 5;
|
||||
imageAdconfiguration.openModel = start_page;
|
||||
imageAdconfiguration.imageNameOrURLString = start_page.image;
|
||||
imageAdconfiguration.showEnterForeground = YES;
|
||||
imageAdconfiguration.imageOption = XHLaunchAdImageRefreshCached;
|
||||
imageAdconfiguration.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
|
||||
}
|
||||
|
||||
#pragma mark - XHLaunchAdDelegate
|
||||
- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenModel:(id)openModel clickPoint:(CGPoint)clickPoint
|
||||
{
|
||||
if(openModel == nil) return;
|
||||
|
||||
if (![openModel isKindOfClass:[StartPage class]]) {
|
||||
return;
|
||||
}
|
||||
|
||||
StartPage *model = openModel;
|
||||
|
||||
//点击跳转类型 1-小说书籍,2-内部链接跳转,3-漫画 4-外部链接
|
||||
switch (model.skip_type) {
|
||||
case 1: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = [model.content integerValue];
|
||||
CYLTabBarController *rootVC = (CYLTabBarController *)[[UIApplication sharedApplication].delegate window].rootViewController;
|
||||
[rootVC.childViewControllers[rootVC.selectedIndex] pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
TFWebViewController *vc = [[TFWebViewController alloc] init];
|
||||
vc.URLString = model.content;
|
||||
CYLTabBarController *rootVC = (CYLTabBarController *)[[UIApplication sharedApplication].delegate window].rootViewController;
|
||||
[rootVC.childViewControllers[rootVC.selectedIndex] pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: {
|
||||
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
|
||||
vc.comic_id = [model.content integerValue];
|
||||
CYLTabBarController *rootVC = (CYLTabBarController *)[[UIApplication sharedApplication].delegate window].rootViewController;
|
||||
[rootVC.childViewControllers[rootVC.selectedIndex] pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:model.content] options:@{} completionHandler:nil];
|
||||
break;
|
||||
case 8: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = [model.content integerValue];
|
||||
CYLTabBarController *rootVC = (CYLTabBarController *)[[UIApplication sharedApplication].delegate window].rootViewController;
|
||||
[rootVC.childViewControllers[rootVC.selectedIndex] pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)xhLaunchAdShowFinish:(XHLaunchAd *)launchAd
|
||||
{
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
}
|
||||
|
||||
#pragma mark - BUSplashAdDelegate
|
||||
#if TF_Enable_Third_Party_Ad
|
||||
- (void)splashAdDidClose:(BUSplashAdView *)splashAd
|
||||
{
|
||||
[splashAd.superview removeFromSuperview];
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
}
|
||||
|
||||
- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError * _Nullable)error
|
||||
{
|
||||
[splashAd.superview removeFromSuperview];
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
}
|
||||
|
||||
- (void)splashAdDidClick:(BUSplashAdView *)splashAd
|
||||
{
|
||||
if (@available(iOS 13.0, *)) {
|
||||
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
|
||||
} else {
|
||||
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// AppDelegate+TFAppSign.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFAppSign)
|
||||
|
||||
- (void)initUserSign;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// AppDelegate+TFAppSign.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFAppSign.h"
|
||||
#import "TFSignAlertView.h"
|
||||
#import "TFSignModel.h"
|
||||
#import "TFCollectionManager.h"
|
||||
|
||||
static NSArray *bookList;
|
||||
|
||||
@implementation AppDelegate (TFAppSign)
|
||||
|
||||
- (void)initUserSign
|
||||
{
|
||||
#if TF_Sign_Mode
|
||||
if (!TFUserInfoManager.isLogin) return;
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[TFNetworkTools POST:Sign_Click parameters:nil model:TFSignModel.class success:^(BOOL isSuccess, TFSignModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
if ((t_model.book.count > 0 || t_model.comic.count > 0) && t_model.award.length > 0 && t_model.tomorrow_award.length > 0) {
|
||||
|
||||
NSMutableArray *t_arr = [NSMutableArray array];
|
||||
|
||||
for (TFProductionModel *t in t_model.book) {
|
||||
t.productionType = TFProductionTypeNovel;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.comic) {
|
||||
t.productionType = TFProductionTypeComic;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.audio) {
|
||||
t.productionType = TFProductionTypeAudio;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
|
||||
TFSignAlertView *alert = [[TFSignAlertView alloc] init];
|
||||
// alert.awardTitle = t_model.award;
|
||||
alert.alertTitle = t_model.award;
|
||||
alert.alertDetailContent = t_model.tomorrow_award;
|
||||
alert.contentLabel.font = kFont11;
|
||||
alert.bookList = [t_arr copy];
|
||||
[alert showAlertView];
|
||||
|
||||
bookList = [t_arr copy];
|
||||
}
|
||||
}
|
||||
} failure:nil];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// AppDelegate+TFCheckSetting.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFCheckSetting)
|
||||
|
||||
- (void)initCheckSetting;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// AppDelegate+TFCheckSetting.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFCheckSetting.h"
|
||||
#import "AppDelegate+TFPopup.h"
|
||||
#import "AppDelegate+TFStartTimes.h"
|
||||
#import "TFUpdateAlertView.h"
|
||||
|
||||
@implementation AppDelegate (TFCheckSetting)
|
||||
|
||||
- (void)initCheckSetting
|
||||
{
|
||||
if ([TFNetworkManager networkingStatus] == NO || [TFNetworkManager currentNetworkStatus] == kCTCellularDataRestrictedStateUnknown) {
|
||||
[TFNetworkManager networkingStatus:^(BOOL status) {
|
||||
if (status == YES) {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Restore_Network object:nil];
|
||||
[self initCheckSetting];
|
||||
});
|
||||
}
|
||||
}];
|
||||
return ;
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkSettingRequestWithState:) name:Notification_Login_Success object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkSettingRequestWithState:) name:Notification_Recharge_Success object:nil];
|
||||
|
||||
[self checkSettingRequestWithState:1];
|
||||
}
|
||||
|
||||
// state == 1 是更新全部数据
|
||||
- (void)checkSettingRequestWithState:(NSInteger)state
|
||||
{
|
||||
WS(weakSelf)
|
||||
|
||||
self.checkSettingModel = [[TFCheckSettingModel alloc] init];
|
||||
|
||||
[TFNetworkTools POST:Check_Setting parameters:nil model:TFCheckSettingModel.class success:^(BOOL isSuccess, TFCheckSettingModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.checkSettingModel = t_model;
|
||||
if (state == 1) {
|
||||
// 更新提醒
|
||||
switch (weakSelf.checkSettingModel.version_update.status) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1: { // 弱更新
|
||||
TFUpdateAlertView *alert = [[TFUpdateAlertView alloc] init];
|
||||
alert.updateMessage = weakSelf.checkSettingModel.version_update.msg;
|
||||
alert.confirmButtonClickBlock = ^{
|
||||
if (weakSelf.checkSettingModel.version_update.url.length > 0) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:weakSelf.checkSettingModel.version_update.url] options:@{} completionHandler:nil];
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"更新地址错误")];
|
||||
}
|
||||
};
|
||||
[alert showAlertView];
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: { // 强更新
|
||||
TFUpdateAlertView *alert = [[TFUpdateAlertView alloc] init];
|
||||
alert.updateMessage = weakSelf.checkSettingModel.version_update.msg ? : @"";
|
||||
alert.alertDisappearType = TFAlertViewDisappearTypeNever;
|
||||
alert.alertBtnType = TFAlertButtonTypeSingleConfirm;
|
||||
alert.confirmButtonClickBlock = ^{
|
||||
if (weakSelf.checkSettingModel.version_update.url.length > 0) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:weakSelf.checkSettingModel.version_update.url] options:@{} completionHandler:nil];
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"更新地址错误")];
|
||||
}
|
||||
};
|
||||
[alert showAlertView];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 过审开关
|
||||
#if TF_Enable_Magic
|
||||
if (weakSelf.checkSettingModel.system_setting.check_status == 1) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Review_State object:@"1"];
|
||||
TFSystemInfoManager.magicStatus = @"1";
|
||||
} else {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Review_State object:@"0"];
|
||||
TFSystemInfoManager.magicStatus = @"0";
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Check_Setting_Update object:nil];
|
||||
}
|
||||
|
||||
// 系统设置参数保存
|
||||
TFSystemInfoManager.masterUnit = weakSelf.checkSettingModel.system_setting.currencyUnit;
|
||||
TFSystemInfoManager.subUnit = weakSelf.checkSettingModel.system_setting.subUnit;
|
||||
|
||||
// 启动页相关
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[weakSelf.checkSettingModel.start_page modelToJSONData] forKey:TF_START_PAGE];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
// 功能状态选择
|
||||
if (weakSelf.checkSettingModel.system_setting.project_type.length > 0) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:weakSelf.checkSettingModel.system_setting.project_type forKey:TF_SITE_STATE];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
// 新版站点状态选择
|
||||
if (weakSelf.checkSettingModel.system_setting.site_type.count > 0) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:weakSelf.checkSettingModel.system_setting.site_type forKey:TF_SITE_STATE];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
// ai开关状态
|
||||
if (weakSelf.checkSettingModel.system_setting.ai_switch == 1) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:TF_Ai_Switch];
|
||||
} else {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:TF_Ai_Switch];
|
||||
}
|
||||
|
||||
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// AppDelegate+TFDeviceID.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFDeviceID)
|
||||
|
||||
- (void)initDeviceInfo;
|
||||
|
||||
- (void)uploadDeviceID:(NSString *)device_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// AppDelegate+TFDeviceID.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFDeviceID.h"
|
||||
#import <MobPush/MobPush.h>
|
||||
|
||||
@implementation AppDelegate (TFDeviceID)
|
||||
|
||||
- (void)uploadDeviceID:(NSString *)device_id
|
||||
{
|
||||
if (kObjectIsEmpty(device_id)) return;
|
||||
|
||||
[TFNetworkTools POST:Upload_Device_Info parameters:@{@"device_id":device_id ? : @""} model:nil success:nil failure:nil];
|
||||
}
|
||||
|
||||
- (void)initDeviceInfo
|
||||
{
|
||||
[self syncDeviceInfo];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(syncDeviceInfo) name:Notification_Login_Success object:nil];
|
||||
}
|
||||
|
||||
- (void)syncDeviceInfo
|
||||
{
|
||||
[MobPush getRegistrationID:^(NSString *registrationID, NSError *error) {
|
||||
[TFNetworkTools POST:Upload_Device_Info parameters:@{@"device_id":registrationID?:@""} model:nil success:nil failure:nil];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// AppDelegate+TFEvaluation.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFEvaluation)
|
||||
|
||||
- (void)initAppStoreScore;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// AppDelegate+TFEvaluation.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFEvaluation.h"
|
||||
#import "AppDelegate+TFStartTimes.h"
|
||||
#import <StoreKit/StoreKit.h>
|
||||
#import "TFEvaluationAlertView.h"
|
||||
|
||||
@implementation AppDelegate (TFEvaluation)
|
||||
|
||||
- (void)initAppStoreScore
|
||||
{
|
||||
#if TF_AppStore_Score
|
||||
if ([self startTimes] % 20 != 0 || [self startTimes] <= 20) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
TFEvaluationAlertView *alert = [[TFEvaluationAlertView alloc] init];
|
||||
alert.confirmButtonClickBlock = ^{
|
||||
if (@available(iOS 10.3, *)) {
|
||||
if([SKStoreReviewController respondsToSelector:@selector(requestReview)]){
|
||||
[[UIApplication sharedApplication].keyWindow endEditing:YES];
|
||||
[SKStoreReviewController requestReview];
|
||||
}
|
||||
}
|
||||
};
|
||||
alert.cancelButtonClickBlock = ^{
|
||||
NSURL *appReviewUrl = [NSURL URLWithString:TF_EvaluationAddress];
|
||||
[[UIApplication sharedApplication] openURL:appReviewUrl options:@{} completionHandler:nil];
|
||||
};
|
||||
[alert showAlertView];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// AppDelegate+TFMobService.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/8.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFMobService)
|
||||
/** 分享 */
|
||||
- (void)initMobShare;
|
||||
|
||||
/** 推送 */
|
||||
- (void)initMobPushWithApplication:(UIApplication *)application launchOptions:(NSDictionary *)launchOptions;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,141 @@
|
||||
//
|
||||
// AppDelegate+TFMobService.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/8.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFMobService.h"
|
||||
#import "TFWebViewController.h"
|
||||
#import <ShareSDK/ShareSDK.h>
|
||||
#import <MobPush/MobPush.h>
|
||||
#import "AppDelegate+TFDeviceID.h"
|
||||
|
||||
@implementation AppDelegate (TFMobService)
|
||||
|
||||
- (void)initMobShare
|
||||
{
|
||||
[ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
|
||||
#if TF_QQ_Share_Mode
|
||||
[platformsRegister setupQQWithAppId:Tencent_APPID appkey:Tencent_APPKey enableUniversalLink:YES universalLink:@"frlln.share2dlink.com/qq_conn/101918139"];
|
||||
#endif
|
||||
|
||||
#if TF_WeChat_Share_Mode
|
||||
[platformsRegister setupWeChatWithAppId:TF_WeChat_APPID appSecret:TF_WeChat_Secret universalLink:@"xiangyoupin.com/app/"];
|
||||
#endif
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)initMobPushWithApplication:(UIApplication *)application launchOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
//#if DEBUG
|
||||
[MobPush setAPNsForProduction:NO];
|
||||
//#else
|
||||
[MobPush setAPNsForProduction:YES];
|
||||
//#endif
|
||||
|
||||
MPushNotificationConfiguration *configuration = [[MPushNotificationConfiguration alloc] init];
|
||||
configuration.types = MPushAuthorizationOptionsBadge | MPushAuthorizationOptionsSound | MPushAuthorizationOptionsAlert;
|
||||
[MobPush setupNotification:configuration];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMessage:) name:MobPushDidReceiveMessageNotification object:nil];
|
||||
|
||||
WS(weakSelf)
|
||||
[MobPush getRegistrationID:^(NSString *registrationID, NSError *error) {
|
||||
[weakSelf uploadDeviceID:registrationID];
|
||||
}];
|
||||
|
||||
[MobPush clearBadge];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rigistrationClick) name:Notification_Switch_Language object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rigistrationClick) name:Notification_Login_Success object:nil];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Private
|
||||
/// 重新注册
|
||||
- (void)rigistrationClick
|
||||
{
|
||||
WS(weakSelf)
|
||||
[MobPush getRegistrationID:^(NSString *registrationID, NSError *error) {
|
||||
if ([[TFViewHelper getCurrentViewController] isKindOfClass:[self class]]) {
|
||||
[TFPromptManager stopAnimating];
|
||||
}
|
||||
[weakSelf uploadDeviceID:registrationID];
|
||||
}];
|
||||
}
|
||||
|
||||
/// 收到通知回调
|
||||
- (void)didReceiveMessage:(NSNotification *)notification
|
||||
{
|
||||
MPushMessage *message = notification.object;
|
||||
NSDictionary *msgInfo = message.notification.userInfo;
|
||||
|
||||
switch (message.messageType) {
|
||||
case MPushMessageTypeCustom: { // 自定义消息
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case MPushMessageTypeAPNs: { // APNs 回调
|
||||
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { // 前台
|
||||
|
||||
} else { // 后台
|
||||
[self pushVC:msgInfo];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MPushMessageTypeLocal: { // 本地通知回调
|
||||
}
|
||||
break;
|
||||
|
||||
case MPushMessageTypeClicked: {
|
||||
|
||||
[self pushVC:msgInfo];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pushVC:(NSDictionary *)msgInfo
|
||||
{
|
||||
if(msgInfo.count > 0) {
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
||||
StartPage *model = [StartPage modelWithDictionary:msgInfo];
|
||||
|
||||
[self.tabBarControllerConfig.tabBarController.navigationController popToRootViewControllerAnimated:NO];
|
||||
[self.tabBarControllerConfig.tabBarController setSelectedIndex:1];
|
||||
|
||||
if(model.content.length>0&&(model.skip_type == 1 ||model.skip_type == 3)){
|
||||
CYLTabBarController *rootVC = (CYLTabBarController *)[[UIApplication sharedApplication].delegate window].rootViewController;
|
||||
|
||||
if (model.skip_type == 1) {
|
||||
|
||||
TFNovelDetailViewController *bookMallDetailVC = [[TFNovelDetailViewController alloc]init];
|
||||
bookMallDetailVC.book_id = [model.content integerValue];
|
||||
[rootVC.childViewControllers[rootVC.selectedIndex] cyl_pushViewController:bookMallDetailVC animated:NO];
|
||||
|
||||
} else if (model.skip_type == 3) {
|
||||
|
||||
TFComicDetailViewController *comicMallDetailVC = [[TFComicDetailViewController alloc]init];
|
||||
comicMallDetailVC.comic_id = [model.content integerValue];
|
||||
[rootVC.childViewControllers[rootVC.selectedIndex] cyl_pushViewController:comicMallDetailVC animated:NO];
|
||||
|
||||
} else {
|
||||
|
||||
TFWebViewController *webViewVC = [[TFWebViewController alloc]init];
|
||||
webViewVC.navTitle = model.title;
|
||||
webViewVC.URLString = model.content;
|
||||
[rootVC.childViewControllers[rootVC.selectedIndex] cyl_pushViewController:webViewVC animated:NO];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// AppDelegate+TFPopup.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFPopup)
|
||||
|
||||
- (void)initInsterestView;
|
||||
|
||||
- (void)updateInsterestData;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// AppDelegate+TFPopup.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFPopup.h"
|
||||
#import "AppDelegate+TFStartTimes.h"
|
||||
#import "TFInterimViewController.h"
|
||||
|
||||
@implementation AppDelegate (TFPopup)
|
||||
|
||||
- (void)initInsterestView
|
||||
{
|
||||
#if TF_Insterest_View
|
||||
if ([TFNetworkManager networkingStatus]) {
|
||||
if ([[NSUserDefaults standardUserDefaults] objectForKey:TF_Insterest_Switch] == nil) {
|
||||
[self.window.rootViewController presentViewController:[[TFInterimViewController alloc] init] animated:NO completion:^{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:TF_Insterest_Switch];
|
||||
}];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateInsterestData) name:Notification_Login_Success object:nil];
|
||||
}
|
||||
|
||||
- (void)updateInsterestData
|
||||
{
|
||||
#if TF_Insterest_View
|
||||
// 上传感兴趣的内容
|
||||
if (TFUserInfoManager.isLogin) {
|
||||
[TFNetworkTools POST:Save_Recommed parameters:@{@"gender":@([TFUserInfoManager shareInstance].gender)} model:nil success:nil failure:nil];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// AppDelegate+TFShortcutTouch.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFShortcutTouch)
|
||||
|
||||
- (void)initShortcutTouch;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// AppDelegate+TFShortcutTouch.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFShortcutTouch.h"
|
||||
#import "TFSearchViewController.h"
|
||||
|
||||
@implementation AppDelegate (TFShortcutTouch)
|
||||
|
||||
- (void)initShortcutTouch
|
||||
{
|
||||
#if TF_ShortcutTouch
|
||||
if (@available(iOS 9.0, *)) {
|
||||
UIApplicationShortcutIcon *searchIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"public_search@3x.png"];
|
||||
UIApplicationShortcutIcon *bookRackIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"public_quick_rack.png"];
|
||||
UIApplicationShortcutIcon *discoverIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"public_quick_discover.png"];
|
||||
|
||||
UIMutableApplicationShortcutItem *searchItem = [[UIMutableApplicationShortcutItem alloc] initWithType:@"search" localizedTitle:TFLocalizedString(@"搜索") localizedSubtitle:nil icon:searchIcon userInfo:nil];
|
||||
UIMutableApplicationShortcutItem *bookRackItem = [[UIMutableApplicationShortcutItem alloc] initWithType:@"bookRack" localizedTitle:TFLocalizedString(@"书架") localizedSubtitle:nil icon:bookRackIcon userInfo:nil];
|
||||
UIMutableApplicationShortcutItem *discoverItem = [[UIMutableApplicationShortcutItem alloc] initWithType:@"discover" localizedTitle:TFLocalizedString(@"发现") localizedSubtitle:nil icon:discoverIcon userInfo:nil];
|
||||
|
||||
[[UIApplication sharedApplication] setShortcutItems:@[searchItem,bookRackItem,discoverItem]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initShortcutTouch) name:Notification_Switch_Language object:nil];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler API_AVAILABLE(ios(9.0))
|
||||
{
|
||||
if (shortcutItem) {
|
||||
[self actionWithShortcutItem:shortcutItem];
|
||||
}
|
||||
|
||||
if (completionHandler) {
|
||||
completionHandler(YES);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)actionWithShortcutItem:(UIApplicationShortcutItem *)item API_AVAILABLE(ios(9.0))
|
||||
{
|
||||
if ([item.type isEqualToString:@"search"]) {
|
||||
|
||||
[self.tabBarControllerConfig.tabBarController setSelectedIndex:1];
|
||||
|
||||
TFSearchViewController *search = [[TFSearchViewController alloc] init];
|
||||
TFNavigationController *nav = [[TFNavigationController alloc] initWithRootViewController:search];
|
||||
[[TFViewHelper getCurrentViewController] presentViewController:nav animated:YES completion:nil];
|
||||
|
||||
} else if ([item.type isEqualToString:@"bookRack"]) {
|
||||
[self.tabBarControllerConfig.tabBarController setSelectedIndex:0];
|
||||
} else if ([item.type isEqualToString:@"discover"]) {
|
||||
[self.tabBarControllerConfig.tabBarController setSelectedIndex:2];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// AppDelegate+TFStartTimes.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate (TFStartTimes)
|
||||
|
||||
- (void)initStartTimes;
|
||||
|
||||
- (int)startTimes;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// AppDelegate+TFStartTimes.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate+TFStartTimes.h"
|
||||
|
||||
@implementation AppDelegate (TFStartTimes)
|
||||
|
||||
- (void)initStartTimes
|
||||
{
|
||||
int startNum = [[[NSUserDefaults standardUserDefaults] objectForKey:@"xtfei_start_num"] intValue];
|
||||
|
||||
if (startNum != 0) {
|
||||
startNum ++;
|
||||
} else {
|
||||
startNum = 1;
|
||||
}
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:startNum] forKey:@"xtfei_start_num"];
|
||||
}
|
||||
|
||||
- (int)startTimes
|
||||
{
|
||||
return [[[NSUserDefaults standardUserDefaults] objectForKey:@"xtfei_start_num"] intValue];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user