123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // AppDelegate+SPSBPopup.m
- // 我的社保
- //
- // Created by shanp on 2021/4/27.
- //
- #import "AppDelegate+SPSBPopup.h"
- #import "SPSBAppProfileModel.h"
- #import <JXHSystemShortcut.h>
- #import "SPSBKeyProfile.h"
- #import "SPSBBusinessManager.h"
- #import "SPSBNetworkManager.h"
- #import "SPSBURLApiProfile.h"
- #import "SPSBPopupADViewController.h"
- #import "SPSBOpenPopupManager.h"
- #import "SPSBPrivacyViewController.h"
- #import <StoreKit/StoreKit.h>
- #import "SPSBAppCommentViewController.h"
- @implementation AppDelegate (SPSBPopup)
- - (void)judegePopup {
- if (![jxh_userDefaults() objectForKey:SPSBPersonalPrivacy]) {
- [self showPrivacy];
- }
- [self judgeIsNeedToComment];
- }
- #pragma mark - 隐私
- - (void)showPrivacy {
- SPSBPrivacyViewController *vc = SPSBPrivacyViewController.new;
- SPSBOpenPopupModel *model = SPSBOpenPopupModel.new;
- model.spsb_popup = vc;
- [SPSBOpenPopupManager insertPopup:model];
- }
- #pragma mark - 评论
- - (void)judgeIsNeedToComment {
- if ([jxh_userDefaults() objectForKey:SPSBFirstOpenApp]) {
- if (![jxh_userDefaults() objectForKey:SPSBCommentApp]) {
- [self performSelector:@selector(autoShowComment) withObject:nil afterDelay:30];
- }
- } else {
- [jxh_userDefaults() setObject:@(true) forKey:SPSBFirstOpenApp];
- [jxh_userDefaults() synchronize];
- }
- }
- - (void)autoShowComment {
- [jxh_userDefaults() setObject:@(true) forKey:SPSBCommentApp];
- [jxh_userDefaults() synchronize];
-
- if (@available(iOS 10.3, *)) {
- [SKStoreReviewController requestReview];
- return;
- }
-
- SPSBAppCommentViewController *vc = SPSBAppCommentViewController.new;
- SPSBOpenPopupModel *model = SPSBOpenPopupModel.new;
- model.spsb_popup = vc;
- [SPSBOpenPopupManager insertPopup:model];
- }
- #pragma mark - 广告弹框
- - (void)judgeAdPopup:(SPSBAppPopImageModel *)data {
- if (![[jxh_userDefaults() objectForKey:SPSBPopupADImagePath] isEqualToString:data.spsb_img]) {
- [self getAdPopoutImageWithData:data];
- return;
- }
- NSDate *new = [NSDate new];
- NSDate *lastPopTime = [jxh_dateFormatter() dateFromString:[jxh_userDefaults() objectForKey:SPSBPopupADTime]];
- if (lastPopTime) {
- NSDate *shouldPopTime = [NSDate dateWithTimeInterval:24 * 60 * 60 sinceDate:lastPopTime];
- if ([new compare:shouldPopTime] >= 0) {
- [self getAdPopoutImageWithData:data];
- }
- } else {
- [self getAdPopoutImageWithData:data];
- }
- }
- - (void)getAdPopoutImageWithData:(SPSBAppPopImageModel *)model {
- [spsb_globalNetworkManager() networkDownloadImageWithUrl:spsb_fileUrl(model.spsb_img) key:@"getAdPopoutImage" completion:^(NSError * _Nonnull error, id _Nullable data) {
- if (error.code == SPSBNetworkErrorCodeSuccess && data[@"image"]) {
- [self showAdPopoutWithImage:data[@"image"] data:model];
- }
- }];
- }
- - (void)showAdPopoutWithImage:(UIImage *)image data:(SPSBAppPopImageModel *)data {
- SPSBPopupADViewController *vc = SPSBPopupADViewController.new;
- vc.spsb_data = data;
- vc.spsb_image = image;
- SPSBOpenPopupModel *model = SPSBOpenPopupModel.new;
- model.spsb_popup = vc;
- [SPSBOpenPopupManager insertPopup:model];
- }
- @end
|