xiaoxi 5 gadi atpakaļ
vecāks
revīzija
2da87c1f64

+ 20 - 0
KXCardHelp.xcodeproj/project.pbxproj

@@ -191,6 +191,8 @@
191 191
 		4AAC10AD21B908DF004BE83C /* WWCheckCardListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AAC10AC21B908DF004BE83C /* WWCheckCardListViewController.m */; };
192 192
 		4AAC10B021B914B2004BE83C /* WWCheckCardListDetailVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AAC10AF21B914B2004BE83C /* WWCheckCardListDetailVC.m */; };
193 193
 		5B982B19B445B1CF86AEC93C /* libPods-KXCardHelp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E6ACD581411C8CD82F0EE3FF /* libPods-KXCardHelp.a */; };
194
+		707B395E21BA1B510004F521 /* NSDictionary+SafeAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 707B395D21BA1B510004F521 /* NSDictionary+SafeAccess.m */; };
195
+		707B396221BA20F40004F521 /* WWRemindMeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 707B396121BA20F40004F521 /* WWRemindMeManager.m */; };
194 196
 /* End PBXBuildFile section */
195 197
 
196 198
 /* Begin PBXCopyFilesBuildPhase section */
@@ -536,6 +538,10 @@
536 538
 		4AAC10AC21B908DF004BE83C /* WWCheckCardListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WWCheckCardListViewController.m; sourceTree = "<group>"; };
537 539
 		4AAC10AE21B914B2004BE83C /* WWCheckCardListDetailVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WWCheckCardListDetailVC.h; sourceTree = "<group>"; };
538 540
 		4AAC10AF21B914B2004BE83C /* WWCheckCardListDetailVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WWCheckCardListDetailVC.m; sourceTree = "<group>"; };
541
+		707B395C21BA1B500004F521 /* NSDictionary+SafeAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+SafeAccess.h"; sourceTree = "<group>"; };
542
+		707B395D21BA1B510004F521 /* NSDictionary+SafeAccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+SafeAccess.m"; sourceTree = "<group>"; };
543
+		707B396021BA20F40004F521 /* WWRemindMeManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WWRemindMeManager.h; sourceTree = "<group>"; };
544
+		707B396121BA20F40004F521 /* WWRemindMeManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WWRemindMeManager.m; sourceTree = "<group>"; };
539 545
 		E6ACD581411C8CD82F0EE3FF /* libPods-KXCardHelp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-KXCardHelp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
540 546
 /* End PBXFileReference section */
541 547
 
@@ -732,6 +738,8 @@
732 738
 		1170B79F20E0C1F000F28085 /* Category */ = {
733 739
 			isa = PBXGroup;
734 740
 			children = (
741
+				707B395C21BA1B500004F521 /* NSDictionary+SafeAccess.h */,
742
+				707B395D21BA1B510004F521 /* NSDictionary+SafeAccess.m */,
735 743
 				110B860720FF0A3200082F55 /* UITable */,
736 744
 				1114D61D20ECCEF60094AC81 /* UIImage */,
737 745
 				1114D61220EB62B70094AC81 /* MBP */,
@@ -1816,6 +1824,7 @@
1816 1824
 		4AAC103A21B508D1004BE83C /* CreditCardManager */ = {
1817 1825
 			isa = PBXGroup;
1818 1826
 			children = (
1827
+				707B395F21BA20CF0004F521 /* Manager */,
1819 1828
 				4AAC103B21B508D1004BE83C /* HomePage */,
1820 1829
 				4AAC104121B508D1004BE83C /* Mine */,
1821 1830
 			);
@@ -1951,6 +1960,15 @@
1951 1960
 			path = JZCheckDataTool;
1952 1961
 			sourceTree = "<group>";
1953 1962
 		};
1963
+		707B395F21BA20CF0004F521 /* Manager */ = {
1964
+			isa = PBXGroup;
1965
+			children = (
1966
+				707B396021BA20F40004F521 /* WWRemindMeManager.h */,
1967
+				707B396121BA20F40004F521 /* WWRemindMeManager.m */,
1968
+			);
1969
+			path = Manager;
1970
+			sourceTree = "<group>";
1971
+		};
1954 1972
 		84E1864C4FDEEAE5A1B51EF6 /* Pods */ = {
1955 1973
 			isa = PBXGroup;
1956 1974
 			children = (
@@ -2245,6 +2263,7 @@
2245 2263
 				119AA01D2138E0350020C78E /* LVKBPersonSafeCenterViewController.m in Sources */,
2246 2264
 				119AA01C2138E0350020C78E /* LVKBPersonChangePwdViewController.m in Sources */,
2247 2265
 				119AA01F2138E0350020C78E /* LVKBPersonSettingViewController.m in Sources */,
2266
+				707B395E21BA1B510004F521 /* NSDictionary+SafeAccess.m in Sources */,
2248 2267
 				4AAC109221B8F9D4004BE83C /* XJCustomWebViewController.m in Sources */,
2249 2268
 				1170B7D520E0F44300F28085 /* LVKBNavigationBar.m in Sources */,
2250 2269
 				11E85CF320F48CB8007B2B0E /* LVKBWebViewController.m in Sources */,
@@ -2259,6 +2278,7 @@
2259 2278
 				1114D62020ECCF290094AC81 /* UIImage+Handle.m in Sources */,
2260 2279
 				1170B7AE20E0C8C100F28085 /* LVKBBaseViewController.m in Sources */,
2261 2280
 				1170B7C220E0D98800F28085 /* UIColor+CHColor.m in Sources */,
2281
+				707B396221BA20F40004F521 /* WWRemindMeManager.m in Sources */,
2262 2282
 				119A9FF52138E0350020C78E /* LVKBHomeReceiptViewController.m in Sources */,
2263 2283
 				119AA02A2138E0350020C78E /* LVKBCheckNineLockViewController.m in Sources */,
2264 2284
 				119A9FF02138E0350020C78E /* LVKBHomeCreditCardTableViewCell.m in Sources */,

+ 14 - 0
KXCardHelp.xcodeproj/xcuserdata/xiaoxi.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -0,0 +1,14 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+	<key>SchemeUserState</key>
6
+	<dict>
7
+		<key>KXCardHelp.xcscheme</key>
8
+		<dict>
9
+			<key>orderHint</key>
10
+			<integer>0</integer>
11
+		</dict>
12
+	</dict>
13
+</dict>
14
+</plist>

BIN
KXCardHelp.xcworkspace/xcuserdata/xiaoxi.xcuserdatad/UserInterfaceState.xcuserstate


+ 17 - 0
KXCardHelp.xcworkspace/xcuserdata/xiaoxi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<Bucket
3
+   type = "0"
4
+   version = "2.0">
5
+   <Breakpoints>
6
+      <BreakpointProxy
7
+         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
8
+         <BreakpointContent
9
+            shouldBeEnabled = "Yes"
10
+            ignoreCount = "0"
11
+            continueAfterRunningActions = "No"
12
+            scope = "1"
13
+            stopOnStyle = "0">
14
+         </BreakpointContent>
15
+      </BreakpointProxy>
16
+   </Breakpoints>
17
+</Bucket>

+ 91 - 5
KXCardHelp/AppDelegate/AppDelegate.m

@@ -34,8 +34,8 @@ UNUserNotificationCenterDelegate
34 34
     [self setUM];                  //友盟统计和微信登录
35 35
     [self setBugly];               //腾讯bugly统计
36 36
     [self setBaiDu];               //设置百度OCR
37
-    [self setXiaoMiPush];          //小米push
38
-    
37
+    [self setXiaoMiPush:launchOptions];          //小米push
38
+    [self setLocalNotion:launchOptions];
39 39
     [self updateVersion];          //版本迭代处理
40 40
     NSNumber *num=[[NSUserDefaults standardUserDefaults]objectForKey:IOS_TYPE];
41 41
     if (num &&[num integerValue]==0) {
@@ -74,10 +74,51 @@ UNUserNotificationCenterDelegate
74 74
 -(void)setBaiDu{
75 75
     [[AipOcrService shardService] authWithAK:BAIDU_APP_ID andSK:BAIDU_SECRET];
76 76
 }
77
-
77
+- (void)setLocalNotion:(NSDictionary *)launchOptions {
78
+    
79
+    if (@available(iOS 8.0, *)) {
80
+        // iOS8以后 本地通知必须注册(获取权限)
81
+        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert categories:nil];
82
+        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
83
+    }
84
+    //如果是这个key有值,代表是杀死的程序接收到本地通知跳转
85
+    if (launchOptions[UIApplicationLaunchOptionsLocationKey]) {
86
+        // 根据这种方式查看launchOptions的内容
87
+        NSLog(@"跳转到指定页面");
88
+    }
89
+}
78 90
 //注册小米push
79
--(void)setXiaoMiPush{
80
-    [MiPushSDK registerMiPush:self];
91
+-(void)setXiaoMiPush:(NSDictionary *)launchOptions{
92
+    if (@available(iOS 10.0, *)) {
93
+        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
94
+        [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) {
95
+            if (granted) {
96
+                //点击允许
97
+                NSLog(@"注册通知成功");
98
+                [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
99
+                    NSLog(@"%@", settings);
100
+                }];
101
+            } else {
102
+                //点击不允许
103
+                NSLog(@"注册通知失败");
104
+            }
105
+        }];
106
+        
107
+        [MiPushSDK registerMiPush:self type:0 connect:YES];
108
+        center.delegate = self;
109
+        
110
+    } else {
111
+        // 注册推送,如果iOS10以下
112
+        [MiPushSDK registerMiPush:self type:0 connect:YES];
113
+    }
114
+    NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
115
+    if (userInfo) {
116
+        NSString *messageId = [userInfo objectForKey:@"_id_"];
117
+        if (messageId!=nil) {
118
+            [MiPushSDK openAppNotify:messageId];
119
+        }
120
+    }
121
+//    [MiPushSDK registerMiPush:self];
81 122
 }
82 123
 
83 124
 //升级版本后操作
@@ -291,6 +332,23 @@ UNUserNotificationCenterDelegate
291 332
     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
292 333
 }
293 334
 #pragma mark UIApplicationDelegate
335
+- (void)application: (UIApplication*)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
336
+    if (notificationSettings.types & UIUserNotificationTypeBadge) {
337
+        NSLog(@"Badge Nofitication type is allowed");
338
+    }
339
+    if (notificationSettings.types & UIUserNotificationTypeAlert) {
340
+        NSLog(@"Alert Notfication type is allowed");
341
+    }
342
+    if (notificationSettings.types & UIUserNotificationTypeSound) {
343
+        NSLog(@"Sound Notfication type is allowed");
344
+    }
345
+}
346
+- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler  API_AVAILABLE(ios(10.0)) {
347
+    completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
348
+}
349
+- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler  API_AVAILABLE(ios(10.0)) {
350
+    completionHandler();
351
+}
294 352
 - (void)application:(UIApplication *)app
295 353
 didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
296 354
 {
@@ -304,6 +362,34 @@ didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
304 362
     // 注册APNS失败
305 363
     // 自行处理
306 364
 }
365
+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
366
+    // 当同时启动APNs与内部长连接时, 把两处收到的消息合并. 通过miPushReceiveNotification返回
367
+    [MiPushSDK handleReceiveRemoteNotification:userInfo];
368
+}
369
+- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
370
+    NSLog(@"收到本地通知");
371
+    // 可以让用户跳转到指定界面 app在前台接收到通知直接跳转界面不太好,所以要判断一下,是从后台进入前台还是本身就在前台
372
+    NSDictionary *userDict = notification.userInfo;
373
+    if (userDict) {
374
+        if ([[userDict valueForKey:@"name"] isEqualToString:@"逾期"]) {
375
+            if ([[userDict valueForKey:@"limit"] isEqual:@1]) {           
376
+                notification.repeatInterval = NSCalendarUnitDay;
377
+            }
378
+        }
379
+    }
380
+    [[UIApplication sharedApplication] cancelLocalNotification:notification];
381
+    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
382
+    
383
+    if (application.applicationState == UIApplicationStateInactive) {// 进入前台时候
384
+        NSLog(@"跳转到指定界面");
385
+        
386
+        // 如果接收到不同的通知,跳转到不同的界面:
387
+        NSLog(@"进行界面的跳转");
388
+        NSLog(@"%@", notification.userInfo);
389
+    } else {
390
+        
391
+    }
392
+}
307 393
 
308 394
 #pragma mark MiPushSDKDelegate
309 395
 

+ 2 - 0
KXCardHelp/AppDelegate/HFile/LVKBClassHeader.h

@@ -53,6 +53,7 @@
53 53
 #import "MBProgressHUD+Extension.h"
54 54
 #import "UIImage+Handle.h"
55 55
 #import "NSDate+JCYEX.h"
56
+#import "NSDictionary+SafeAccess.h"
56 57
 /*其余类*/
57 58
 #import "MLMSegmentManager.h"
58 59
 #import "PublicFunction.h"
@@ -62,6 +63,7 @@
62 63
 #import "RSAUtil.h"
63 64
 #import "UITableView+CHHandle.h"
64 65
 #import "YDFMDB.h"
66
+#import "WWRemindMeManager.h"
65 67
 
66 68
 /*工具类*/
67 69
 #import "JZGetHeightTool.h"         //获取h高度

+ 88 - 0
KXCardHelp/Category/NSDictionary+SafeAccess.h

@@ -0,0 +1,88 @@
1
+//
2
+//  NSDictionary+SafeAccess.h
3
+//  IOS-Categories
4
+//
5
+//  Created by Jakey on 15/1/25.
6
+//  Copyright (c) 2015年 www.skyfox.org. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+#import <UIKit/UIKit.h>
11
+
12
+@interface NSDictionary (SafeAccess)
13
+- (BOOL)hasKey:(NSString *)key;
14
+
15
+- (NSString*)stringForKey:(id)key;
16
+
17
+- (NSNumber*)numberForKey:(id)key;
18
+
19
+- (NSArray*)arrayForKey:(id)key;
20
+
21
+- (NSDictionary*)dictionaryForKey:(id)key;
22
+
23
+- (NSInteger)integerForKey:(id)key;
24
+
25
+- (NSUInteger)unsignedIntegerForKey:(id)key;
26
+
27
+- (BOOL)boolForKey:(id)key;
28
+
29
+- (int16_t)int16ForKey:(id)key;
30
+
31
+- (int32_t)int32ForKey:(id)key;
32
+
33
+- (int64_t)int64ForKey:(id)key;
34
+
35
+- (char)charForKey:(id)key;
36
+
37
+- (short)shortForKey:(id)key;
38
+
39
+- (float)floatForKey:(id)key;
40
+
41
+- (double)doubleForKey:(id)key;
42
+
43
+- (long long)longLongForKey:(id)key;
44
+
45
+- (unsigned long long)unsignedLongLongForKey:(id)key;
46
+
47
+//CG
48
+- (CGFloat)CGFloatForKey:(id)key;
49
+
50
+- (CGPoint)pointForKey:(id)key;
51
+
52
+- (CGSize)sizeForKey:(id)key;
53
+
54
+- (CGRect)rectForKey:(id)key;
55
+@end
56
+
57
+#pragma --mark NSMutableDictionary setter
58
+
59
+@interface NSMutableDictionary(SafeAccess)
60
+
61
+-(void)setObj:(id)i forKey:(NSString*)key;
62
+
63
+-(void)setString:(NSString*)i forKey:(NSString*)key;
64
+
65
+-(void)setBool:(BOOL)i forKey:(NSString*)key;
66
+
67
+-(void)setInt:(int)i forKey:(NSString*)key;
68
+
69
+-(void)setInteger:(NSInteger)i forKey:(NSString*)key;
70
+
71
+-(void)setUnsignedInteger:(NSUInteger)i forKey:(NSString*)key;
72
+
73
+-(void)setCGFloat:(CGFloat)f forKey:(NSString*)key;
74
+
75
+-(void)setChar:(char)c forKey:(NSString*)key;
76
+
77
+-(void)setFloat:(float)i forKey:(NSString*)key;
78
+
79
+-(void)setDouble:(double)i forKey:(NSString*)key;
80
+
81
+-(void)setLongLong:(long long)i forKey:(NSString*)key;
82
+
83
+-(void)setPoint:(CGPoint)o forKey:(NSString*)key;
84
+
85
+-(void)setSize:(CGSize)o forKey:(NSString*)key;
86
+
87
+-(void)setRect:(CGRect)o forKey:(NSString*)key;
88
+@end

+ 326 - 0
KXCardHelp/Category/NSDictionary+SafeAccess.m

@@ -0,0 +1,326 @@
1
+//
2
+//  NSDictionary+SafeAccess.m
3
+//  IOS-Categories
4
+//
5
+//  Created by Jakey on 15/1/25.
6
+//  Copyright (c) 2015年 www.skyfox.org. All rights reserved.
7
+//
8
+
9
+#import "NSDictionary+SafeAccess.h"
10
+
11
+@implementation NSDictionary (SafeAccess)
12
+- (BOOL)hasKey:(NSString *)key
13
+{
14
+    return [self objectForKey:key] != nil;
15
+}
16
+
17
+- (NSString*)stringForKey:(id)key
18
+{
19
+    id value = [self objectForKey:key];
20
+    if (value == nil || value == [NSNull null])
21
+    {
22
+        return nil;
23
+    }
24
+    if ([value isKindOfClass:[NSString class]]) {
25
+        return (NSString*)value;
26
+    }
27
+    if ([value isKindOfClass:[NSNumber class]]) {
28
+       return [value stringValue];
29
+    }
30
+    
31
+    return nil;
32
+}
33
+
34
+- (NSNumber*)numberForKey:(id)key
35
+{
36
+    id value = [self objectForKey:key];
37
+    if ([value isKindOfClass:[NSNumber class]]) {
38
+        return (NSNumber*)value;
39
+    }
40
+    if ([value isKindOfClass:[NSString class]]) {
41
+        NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
42
+        [f setNumberStyle:NSNumberFormatterDecimalStyle];
43
+        return [f numberFromString:(NSString*)value];
44
+    }
45
+    return nil;
46
+}
47
+
48
+- (NSArray*)arrayForKey:(id)key
49
+{
50
+    id value = [self objectForKey:key];
51
+    if (value == nil || value == [NSNull null])
52
+    {
53
+        return nil;
54
+    }
55
+    if ([value isKindOfClass:[NSArray class]])
56
+    {
57
+        return value;
58
+    }
59
+    return nil;
60
+}
61
+
62
+- (NSDictionary*)dictionaryForKey:(id)key
63
+{
64
+    id value = [self objectForKey:key];
65
+    if (value == nil || value == [NSNull null])
66
+    {
67
+        return nil;
68
+    }
69
+    if ([value isKindOfClass:[NSDictionary class]])
70
+    {
71
+        return value;
72
+    }
73
+    return nil;
74
+}
75
+
76
+- (NSInteger)integerForKey:(id)key
77
+{
78
+    id value = [self objectForKey:key];
79
+    if (value == nil || value == [NSNull null])
80
+    {
81
+        return 0;
82
+    }
83
+    if ([value isKindOfClass:[NSString class]] || [value isKindOfClass:[NSNumber class]])
84
+    {
85
+        return [value integerValue];
86
+    }
87
+    return 0;
88
+}
89
+- (NSUInteger)unsignedIntegerForKey:(id)key{
90
+    id value = [self objectForKey:key];
91
+    if (value == nil || value == [NSNull null])
92
+    {
93
+        return 0;
94
+    }
95
+    if ([value isKindOfClass:[NSString class]] || [value isKindOfClass:[NSNumber class]])
96
+    {
97
+        return [value unsignedIntegerValue];
98
+    }
99
+    return 0;
100
+}
101
+- (BOOL)boolForKey:(id)key
102
+{
103
+    id value = [self objectForKey:key];
104
+    
105
+    if (value == nil || value == [NSNull null])
106
+    {
107
+        return NO;
108
+    }
109
+    if ([value isKindOfClass:[NSNumber class]])
110
+    {
111
+        return [value boolValue];
112
+    }
113
+    if ([value isKindOfClass:[NSString class]])
114
+    {
115
+        return [value boolValue];
116
+    }
117
+    return NO;
118
+}
119
+- (int16_t)int16ForKey:(id)key
120
+{
121
+    id value = [self objectForKey:key];
122
+    
123
+    if (value == nil || value == [NSNull null])
124
+    {
125
+        return 0;
126
+    }
127
+    if ([value isKindOfClass:[NSNumber class]])
128
+    {
129
+        return [value shortValue];
130
+    }
131
+    if ([value isKindOfClass:[NSString class]])
132
+    {
133
+        return [value intValue];
134
+    }
135
+    return 0;
136
+}
137
+- (int32_t)int32ForKey:(id)key
138
+{
139
+    id value = [self objectForKey:key];
140
+    
141
+    if (value == nil || value == [NSNull null])
142
+    {
143
+        return 0;
144
+    }
145
+    if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]])
146
+    {
147
+        return [value intValue];
148
+    }
149
+    return 0;
150
+}
151
+- (int64_t)int64ForKey:(id)key
152
+{
153
+    id value = [self objectForKey:key];
154
+    
155
+    if (value == nil || value == [NSNull null])
156
+    {
157
+        return 0;
158
+    }
159
+    if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]])
160
+    {
161
+        return [value longLongValue];
162
+    }
163
+    return 0;
164
+}
165
+- (char)charForKey:(id)key{
166
+    id value = [self objectForKey:key];
167
+    
168
+    if (value == nil || value == [NSNull null])
169
+    {
170
+        return 0;
171
+    }
172
+    if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]])
173
+    {
174
+        return [value charValue];
175
+    }
176
+    return 0;
177
+}
178
+- (short)shortForKey:(id)key
179
+{
180
+    id value = [self objectForKey:key];
181
+    
182
+    if (value == nil || value == [NSNull null])
183
+    {
184
+        return 0;
185
+    }
186
+    if ([value isKindOfClass:[NSNumber class]])
187
+    {
188
+        return [value shortValue];
189
+    }
190
+    if ([value isKindOfClass:[NSString class]])
191
+    {
192
+        return [value intValue];
193
+    }
194
+    return 0;
195
+}
196
+- (float)floatForKey:(id)key
197
+{
198
+    id value = [self objectForKey:key];
199
+    
200
+    if (value == nil || value == [NSNull null])
201
+    {
202
+        return 0;
203
+    }
204
+    if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]])
205
+    {
206
+        return [value floatValue];
207
+    }
208
+    return 0;
209
+}
210
+- (double)doubleForKey:(id)key
211
+{
212
+    id value = [self objectForKey:key];
213
+    
214
+    if (value == nil || value == [NSNull null])
215
+    {
216
+        return 0;
217
+    }
218
+    if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]])
219
+    {
220
+        return [value doubleValue];
221
+    }
222
+    return 0;
223
+}
224
+- (long long)longLongForKey:(id)key
225
+{
226
+    id value = [self objectForKey:key];
227
+    if ([value isKindOfClass:[NSString class]] || [value isKindOfClass:[NSNumber class]]) {
228
+        return [value longLongValue];
229
+    }
230
+    return 0;
231
+}
232
+
233
+- (unsigned long long)unsignedLongLongForKey:(id)key
234
+{
235
+    id value = [self objectForKey:key];
236
+    if ([value isKindOfClass:[NSString class]]) {
237
+        NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
238
+        value = [nf numberFromString:value];
239
+    }
240
+    if ([value isKindOfClass:[NSNumber class]]) {
241
+        return [value unsignedLongLongValue];
242
+    }
243
+    return 0;
244
+}
245
+//CG
246
+- (CGFloat)CGFloatForKey:(id)key
247
+{
248
+    CGFloat f = [self[key] doubleValue];
249
+    return f;
250
+}
251
+
252
+- (CGPoint)pointForKey:(id)key
253
+{
254
+    CGPoint point = CGPointFromString(self[key]);
255
+    return point;
256
+}
257
+- (CGSize)sizeForKey:(id)key
258
+{
259
+    CGSize size = CGSizeFromString(self[key]);
260
+    return size;
261
+}
262
+- (CGRect)rectForKey:(id)key
263
+{
264
+    CGRect rect = CGRectFromString(self[key]);
265
+    return rect;
266
+}
267
+@end
268
+
269
+#pragma --mark NSMutableDictionary setter
270
+@implementation NSMutableDictionary (SafeAccess)
271
+-(void)setObj:(id)i forKey:(NSString*)key{
272
+    if (i!=nil) {
273
+        self[key] = i;
274
+    }
275
+}
276
+-(void)setString:(NSString*)i forKey:(NSString*)key;
277
+{
278
+    [self setValue:i forKey:key];
279
+}
280
+-(void)setBool:(BOOL)i forKey:(NSString *)key
281
+{
282
+    self[key] = @(i);
283
+}
284
+-(void)setInt:(int)i forKey:(NSString *)key
285
+{
286
+    self[key] = @(i);
287
+}
288
+-(void)setInteger:(NSInteger)i forKey:(NSString *)key
289
+{
290
+    self[key] = @(i);
291
+}
292
+-(void)setUnsignedInteger:(NSUInteger)i forKey:(NSString *)key
293
+{
294
+    self[key] = @(i);
295
+}
296
+-(void)setCGFloat:(CGFloat)f forKey:(NSString *)key
297
+{
298
+    self[key] = @(f);
299
+}
300
+-(void)setChar:(char)c forKey:(NSString *)key
301
+{
302
+    self[key] = @(c);
303
+}
304
+-(void)setFloat:(float)i forKey:(NSString *)key
305
+{
306
+    self[key] = @(i);
307
+}
308
+-(void)setDouble:(double)i forKey:(NSString*)key{
309
+    self[key] = @(i);
310
+}
311
+-(void)setLongLong:(long long)i forKey:(NSString*)key{
312
+    self[key] = @(i);
313
+}
314
+-(void)setPoint:(CGPoint)o forKey:(NSString *)key
315
+{
316
+    self[key] = NSStringFromCGPoint(o);
317
+}
318
+-(void)setSize:(CGSize)o forKey:(NSString *)key
319
+{
320
+    self[key] = NSStringFromCGSize(o);
321
+}
322
+-(void)setRect:(CGRect)o forKey:(NSString *)key
323
+{
324
+    self[key] = NSStringFromCGRect(o);
325
+}
326
+@end

+ 9 - 0
KXCardHelp/Main/CheckPage/CreditCardManager/HomePage/Controller/WWCheckHomeViewController.m

@@ -107,6 +107,15 @@ static NSString *cellID = @"cellID";
107 107
         [self.tableHeaderView addSubview:self.cardDataView];
108 108
         
109 109
         NSArray *array = [NSArray yy_modelArrayWithClass:[WWCheckCardListModel class] json:json[@"card_list"]];
110
+        
111
+        NSMutableArray *mutArr = [NSMutableArray arrayWithCapacity:50];
112
+        for (WWCheckCardListModel *model in array) {
113
+            NSData *data = [NSKeyedArchiver archivedDataWithRootObject:model];
114
+            [mutArr addObject:data];
115
+        }
116
+        [[NSUserDefaults standardUserDefaults] setObject:mutArr forKey:kLocalCardListArray];
117
+        [[NSUserDefaults standardUserDefaults] synchronize];
118
+        
110 119
         [self.dataArray addObjectsFromArray:array];
111 120
         [self.tableView reloadData];
112 121
         

+ 62 - 13
KXCardHelp/Main/CheckPage/CreditCardManager/HomePage/Controller/WWCheckRemindMeViewController.m

@@ -18,11 +18,18 @@ static NSString *cellID = @"cellID";
18 18
 
19 19
 @property (nonatomic, strong)UITableView *tableView;             //tableView
20 20
 @property (nonatomic, strong)NSMutableArray *statusArray;    //提醒开关状态
21
-
21
+@property (nonatomic, strong)WWRemindMeManager *manager;
22 22
 @end
23 23
 
24 24
 @implementation WWCheckRemindMeViewController
25 25
 
26
+- (WWRemindMeManager *)manager {
27
+    if (!_manager) {
28
+        _manager = [WWRemindMeManager shared];
29
+    }
30
+    return _manager;
31
+}
32
+
26 33
 - (void)viewDidLoad {
27 34
     [super viewDidLoad];
28 35
     // Do any additional setup after loading the view.
@@ -49,12 +56,16 @@ static NSString *cellID = @"cellID";
49 56
 
50 57
 #pragma mark - 配置数据
51 58
 - (void)createStatusArray {
52
-    self.statusArray = [[NSUserDefaults standardUserDefaults] objectForKey:checkRemindStatusArray];
59
+    self.statusArray = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:checkRemindStatusArray]];
53 60
     if (self.statusArray == nil) {
54 61
         self.statusArray = [NSMutableArray array];
55
-        NSMutableDictionary *dict1 = [[NSMutableDictionary alloc] initWithDictionary:@{@"isOn" : @(NO), @"time" : @"出账日当天"}];
56
-        NSMutableDictionary *dict2 = [[NSMutableDictionary alloc] initWithDictionary:@{@"isOn" : @(NO), @"time" : @"还款日当天"}];
57
-        NSMutableDictionary *dict3 = [[NSMutableDictionary alloc] initWithDictionary:@{@"isOn" : @(NO), @"time" : @"超过还款日当天"}];
62
+        NSMutableDictionary *dict1 = [[NSMutableDictionary alloc] initWithDictionary:@{@"isOn" : @(NO), @"time" : @"出账日当天", @"limit": @0}];
63
+        NSMutableDictionary *dict2 = [[NSMutableDictionary alloc] initWithDictionary:@{@"isOn" : @(NO), @"time" : @"还款日当天", @"limit": @0}];
64
+        NSMutableDictionary *dict3 = [[NSMutableDictionary alloc] initWithDictionary:@{@"isOn" : @(NO), @"time" : @"超过还款日当天", @"limit": @0}];
65
+        
66
+        [self.manager setBillStatus:NO];
67
+        [self.manager setRefundStatus:NO];
68
+        [self.manager setOverdueStatus:NO];
58 69
         
59 70
         [self.statusArray addObject:dict1];
60 71
         [self.statusArray addObject:dict2];
@@ -101,7 +112,7 @@ static NSString *cellID = @"cellID";
101 112
     [headerView addSubview:titleLabel];
102 113
     
103 114
     
104
-    NSMutableDictionary *isOnDict = self.statusArray[section];
115
+    NSDictionary *isOnDict = self.statusArray[section];
105 116
     BOOL swStatus = [isOnDict[@"isOn"] boolValue];
106 117
     
107 118
     //开关
@@ -134,7 +145,7 @@ static NSString *cellID = @"cellID";
134 145
 }
135 146
 
136 147
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
137
-    NSMutableDictionary *isOnDict = self.statusArray[indexPath.section];
148
+    NSDictionary *isOnDict = self.statusArray[indexPath.section];
138 149
     
139 150
     WWCheckRemindMeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
140 151
     cell.selectionStyle = UITableViewCellSelectionStyleNone;
@@ -161,9 +172,11 @@ static NSString *cellID = @"cellID";
161 172
     pickerView.valueDidSelect = ^(NSString *value){
162 173
         NSArray * stateArr = [value componentsSeparatedByString:@"/"];
163 174
         
164
-        NSMutableDictionary *isOnDict = self.statusArray[indexPath.section];
165
-        [isOnDict setValue:stateArr.firstObject forKey:@"time"];
166
-        [self.statusArray replaceObjectAtIndex:indexPath.section withObject:isOnDict];
175
+        NSDictionary *isOnDict = self.statusArray[indexPath.section];
176
+        NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:isOnDict];
177
+        [mutDict setValue:stateArr.firstObject forKey:@"time"];
178
+        [mutDict setValue:stateArr[1] forKey:@"limit"];
179
+        [self.statusArray replaceObjectAtIndex:indexPath.section withObject:mutDict];
167 180
         [[NSUserDefaults standardUserDefaults] setObject:self.statusArray forKey:checkRemindStatusArray];
168 181
         
169 182
         WWCheckRemindMeCell *cell = [tableView cellForRowAtIndexPath:indexPath];
@@ -183,14 +196,50 @@ static NSString *cellID = @"cellID";
183 196
 #pragma mark - 打开/关闭 开关
184 197
 - (void)onClickSwich:(UISwitch *)swich {
185 198
     
186
-    NSMutableDictionary *isOnDict = self.statusArray[swich.tag - 666];
187
-    [isOnDict setValue:@(swich.on) forKey:@"isOn"];
188
-    [self.statusArray replaceObjectAtIndex:(swich.tag - 666) withObject:isOnDict];
199
+    NSDictionary *isOnDict = self.statusArray[swich.tag - 666];
200
+    NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:isOnDict];
201
+    [mutDict setValue:@(swich.isOn) forKey:@"isOn"];
202
+    [self.statusArray replaceObjectAtIndex:(swich.tag - 666) withObject:mutDict];
189 203
     [[NSUserDefaults standardUserDefaults] setObject:self.statusArray forKey:checkRemindStatusArray];
190 204
     [[NSUserDefaults standardUserDefaults] synchronize];
191 205
     [self.tableView reloadData];
192 206
     
193 207
     // 打开/关闭开关  遍历信用卡账单日 注册/删除 本地通知
208
+    switch (swich.tag-666) {
209
+        case 0:
210
+        {
211
+            [self.manager setBillStatus:swich.isOn];
212
+            if (swich.isOn) {
213
+                [self.manager managerBillRegisterAll];
214
+            } else {
215
+                [self.manager managerBillRemoveAll];
216
+            }
217
+        }
218
+            break;
219
+        case 1:
220
+        {
221
+            [self.manager setRefundStatus:swich.isOn];
222
+            if (swich.isOn) {
223
+                [self.manager managerRefundRegisterAll];
224
+            } else {
225
+                [self.manager managerRefundRemoveAll];
226
+            }
227
+        }
228
+            break;
229
+        case 2:
230
+        {
231
+            [self.manager setOverdueStatus:swich.isOn];
232
+            if (swich.isOn) {
233
+                [self.manager managerOverdueRegisterAll];
234
+            } else {
235
+                [self.manager managerOverdueRemoveAll];
236
+            }
237
+        }
238
+            break;
239
+        default:
240
+            break;
241
+    }
242
+    
194 243
 }
195 244
 
196 245
 #pragma mark - 懒加载

+ 1 - 1
KXCardHelp/Main/CheckPage/CreditCardManager/HomePage/Model/WWCheckCardListModel.h

@@ -10,7 +10,7 @@
10 10
 
11 11
 NS_ASSUME_NONNULL_BEGIN
12 12
 
13
-@interface WWCheckCardListModel : NSObject
13
+@interface WWCheckCardListModel : NSObject <YYModel, NSCoding>
14 14
 
15 15
 @property (nonatomic, copy)NSString *bank_name;
16 16
 @property (nonatomic, copy)NSString *bill_account;

+ 8 - 0
KXCardHelp/Main/CheckPage/CreditCardManager/HomePage/Model/WWCheckCardListModel.m

@@ -14,4 +14,12 @@
14 14
     return @{@"ID" : @"id"};
15 15
 }
16 16
 
17
+- (void)encodeWithCoder:(NSCoder *)aCoder {
18
+    [self yy_modelEncodeWithCoder:aCoder];
19
+}
20
+
21
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
22
+    return [self yy_modelInitWithCoder:aDecoder];
23
+}
24
+
17 25
 @end

+ 34 - 0
KXCardHelp/Main/CheckPage/CreditCardManager/Manager/WWRemindMeManager.h

@@ -0,0 +1,34 @@
1
+//
2
+//  WWRemindMeManager.h
3
+//  KXCardHelp
4
+//
5
+//  Created by xiaoxi on 2018/12/7.
6
+//  Copyright © 2018 jcymac. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+
11
+NS_ASSUME_NONNULL_BEGIN
12
+
13
+static NSString *kLocalCardListArray = @"kLocalCardListArray";
14
+
15
+@class WWCheckCardListModel;
16
+
17
+@interface WWRemindMeManager : NSObject
18
+
19
++ (instancetype)shared;
20
+- (void)setBillStatus:(BOOL)status;
21
+- (void)setRefundStatus:(BOOL)status;
22
+- (void)setOverdueStatus:(BOOL)status;
23
+- (void)managerRegister:(WWCheckCardListModel *)card;
24
+- (void)managerRemove:(WWCheckCardListModel *)card;
25
+- (void)managerBillRegisterAll;
26
+- (void)managerBillRemoveAll;
27
+- (void)managerRefundRegisterAll;
28
+- (void)managerRefundRemoveAll;
29
+- (void)managerOverdueRegisterAll;
30
+- (void)managerOverdueRemoveAll;
31
+
32
+@end
33
+
34
+NS_ASSUME_NONNULL_END

+ 184 - 0
KXCardHelp/Main/CheckPage/CreditCardManager/Manager/WWRemindMeManager.m

@@ -0,0 +1,184 @@
1
+//
2
+//  WWRemindMeManager.m
3
+//  KXCardHelp
4
+//
5
+//  Created by xiaoxi on 2018/12/7.
6
+//  Copyright © 2018 jcymac. All rights reserved.
7
+//
8
+
9
+#import "WWRemindMeManager.h"
10
+#import "WWCheckCardListModel.h"
11
+
12
+static NSString *kBillStatus = @"kBillStatus";
13
+static NSString *kRefundStatus = @"kRefundStatus";
14
+static NSString *kOverdueStatus = @"kOverdueStatus";
15
+
16
+@implementation WWRemindMeManager
17
+
18
+static WWRemindMeManager *manager = nil;
19
++ (instancetype)shared {
20
+    static dispatch_once_t onceToken;
21
+    dispatch_once(&onceToken, ^{
22
+        manager = [[WWRemindMeManager alloc] init];
23
+    });
24
+    return manager;
25
+}
26
+
27
+- (void)setBillStatus:(BOOL)status {
28
+    [[NSUserDefaults standardUserDefaults] setBool:status forKey:kBillStatus];
29
+    [[NSUserDefaults standardUserDefaults] synchronize];
30
+}
31
+
32
+- (void)setRefundStatus:(BOOL)status {
33
+    [[NSUserDefaults standardUserDefaults] setBool:status forKey:kRefundStatus];
34
+    [[NSUserDefaults standardUserDefaults] synchronize];
35
+}
36
+
37
+- (void)setOverdueStatus:(BOOL)status {
38
+    [[NSUserDefaults standardUserDefaults] setBool:status forKey:kOverdueStatus];
39
+    [[NSUserDefaults standardUserDefaults] synchronize];
40
+}
41
+
42
+- (BOOL)managerStatus {
43
+    BOOL billStatus = [[NSUserDefaults standardUserDefaults] boolForKey:kBillStatus];
44
+    BOOL refundStatus = [[NSUserDefaults standardUserDefaults] boolForKey:kRefundStatus];
45
+    BOOL overdueStatus = [[NSUserDefaults standardUserDefaults] boolForKey:kOverdueStatus];
46
+    return (billStatus || refundStatus || overdueStatus) ;
47
+}
48
+
49
+- (void)managerRemove:(WWCheckCardListModel *)card {
50
+    if ([self managerStatus]) {
51
+        NSArray *arr = [[UIApplication sharedApplication] scheduledLocalNotifications];
52
+        [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
53
+            UILocalNotification *localNoti = (UILocalNotification *)obj;
54
+            if ([localNoti.alertBody containsString:card.bill_account]) {
55
+                [[UIApplication sharedApplication] cancelLocalNotification:localNoti];
56
+            }
57
+        }];
58
+    }
59
+}
60
+
61
+- (void)managerRegister:(WWCheckCardListModel *)card {
62
+    if ([self managerStatus]) {
63
+        NSArray *statusArr = [[NSUserDefaults standardUserDefaults] objectForKey:checkRemindStatusArray];
64
+        BOOL billStatus = [[NSUserDefaults standardUserDefaults] boolForKey:kBillStatus];
65
+        if (billStatus) {
66
+            NSDictionary *isOnDict = statusArr[0];
67
+            [self managerRegisterLocalNotificationWithParm:isOnDict card:card name:@"出账"];
68
+        }
69
+        BOOL refundStatus = [[NSUserDefaults standardUserDefaults] boolForKey:kRefundStatus];
70
+        if (refundStatus) {
71
+            NSDictionary *isOnDict = statusArr[1];
72
+            [self managerRegisterLocalNotificationWithParm:isOnDict card:card name:@"还款"];
73
+        }
74
+        BOOL overdueStatus = [[NSUserDefaults standardUserDefaults] boolForKey:kOverdueStatus];
75
+        if (overdueStatus) {
76
+            NSDictionary *isOnDict = statusArr[2];
77
+            [self managerRegisterLocalNotificationWithParm:isOnDict card:card name:@"逾期"];
78
+        }
79
+    }
80
+}
81
+
82
+- (void)managerBillRemoveAll {
83
+    NSArray *arr = [[UIApplication sharedApplication] scheduledLocalNotifications];
84
+    [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
85
+        UILocalNotification *localNoti = (UILocalNotification *)obj;
86
+        if ([localNoti.userInfo[@"name"] isEqualToString:@"出账"]) {
87
+            [[UIApplication sharedApplication] cancelLocalNotification:localNoti];
88
+        }
89
+    }];
90
+}
91
+
92
+- (void)managerBillRegisterAll {
93
+    NSArray *localArr = [[NSUserDefaults standardUserDefaults] objectForKey:kLocalCardListArray];
94
+    if (localArr && localArr.count > 0) {
95
+        NSArray *statusArr = [[NSUserDefaults standardUserDefaults] objectForKey:checkRemindStatusArray];
96
+        [localArr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
97
+            NSData *data = (NSData *)obj;
98
+            WWCheckCardListModel *card = [NSKeyedUnarchiver unarchiveObjectWithData:data];
99
+            NSDictionary *isOnDict = statusArr[0];
100
+            [self managerRegisterLocalNotificationWithParm:isOnDict card:card name:@"出账"];
101
+        }];
102
+    }
103
+}
104
+
105
+- (void)managerRefundRemoveAll {
106
+    NSArray *arr = [[UIApplication sharedApplication] scheduledLocalNotifications];
107
+    [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
108
+        UILocalNotification *localNoti = (UILocalNotification *)obj;
109
+        if ([localNoti.userInfo[@"name"] isEqualToString:@"还款"]) {
110
+            [[UIApplication sharedApplication] cancelLocalNotification:localNoti];
111
+        }
112
+    }];
113
+}
114
+
115
+- (void)managerRefundRegisterAll {
116
+    NSArray *localArr = [[NSUserDefaults standardUserDefaults] objectForKey:kLocalCardListArray];
117
+    if (localArr && localArr.count > 0) {
118
+        NSArray *statusArr = [[NSUserDefaults standardUserDefaults] objectForKey:checkRemindStatusArray];
119
+        [localArr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
120
+            NSData *data = (NSData *)obj;
121
+            WWCheckCardListModel *card = [NSKeyedUnarchiver unarchiveObjectWithData:data];
122
+            NSDictionary *isOnDict = statusArr[1];
123
+            [self managerRegisterLocalNotificationWithParm:isOnDict card:card name:@"还款"];
124
+        }];
125
+    }
126
+}
127
+
128
+- (void)managerOverdueRemoveAll {
129
+    NSArray *arr = [[UIApplication sharedApplication] scheduledLocalNotifications];
130
+    [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
131
+        UILocalNotification *localNoti = (UILocalNotification *)obj;
132
+        if ([localNoti.userInfo[@"name"] isEqualToString:@"逾期"]) {
133
+            [[UIApplication sharedApplication] cancelLocalNotification:localNoti];
134
+        }
135
+    }];
136
+}
137
+
138
+- (void)managerOverdueRegisterAll {
139
+    NSArray *localArr = [[NSUserDefaults standardUserDefaults] objectForKey:kLocalCardListArray];
140
+    if (localArr && localArr.count > 0) {
141
+        NSArray *statusArr = [[NSUserDefaults standardUserDefaults] objectForKey:checkRemindStatusArray];
142
+        [localArr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
143
+            NSData *data = (NSData *)obj;
144
+            WWCheckCardListModel *card = [NSKeyedUnarchiver unarchiveObjectWithData:data];
145
+            NSDictionary *isOnDict = statusArr[2];
146
+            [self managerRegisterLocalNotificationWithParm:isOnDict card:card name:@"逾期"];
147
+        }];
148
+    }
149
+}
150
+
151
+- (void)managerRegisterLocalNotificationWithParm:(NSDictionary *)parm card:(WWCheckCardListModel *)card name:(NSString *)name {
152
+//    if (@available(iOS 10.0, *)) {
153
+//        NSDateComponents *components = [[NSDateComponents alloc] init];
154
+//        NSDate *date = [NSDate dateWithTimeIntervalSince1970:[card.due_date longValue]/1000];
155
+//
156
+//        components.date = [NSDate dateWithTimeInterval:10*60*60+24*60*60 sinceDate:];
157
+//        UNCalendarNotificationTrigger *calendarTrigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:YES];
158
+//        UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
159
+//        content.body = [NSString stringWithFormat:@"%@%@啦",card.bill_account,name];
160
+//        UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:card.bill_account content:content trigger:calendarTrigger];
161
+//        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
162
+//        [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
163
+//
164
+//        }];
165
+//    } else {
166
+//
167
+//    }
168
+    UILocalNotification *localNote = [[UILocalNotification alloc] init];
169
+    localNote.timeZone = [NSTimeZone defaultTimeZone];
170
+    NSNumber *limit = [parm valueForKey:@"limit"];
171
+    if ([name isEqualToString:@"逾期"]) {
172
+        localNote.fireDate = [NSDate dateWithTimeInterval:10*60*60+24*60*60 sinceDate:[NSDate dateWithTimeIntervalSince1970:[card.due_date longValue]]];
173
+    } else {
174
+        localNote.fireDate = [NSDate dateWithTimeInterval:10*60*60-24*60*60*limit.intValue sinceDate:[NSDate dateWithTimeIntervalSince1970:[card.due_date longValue]]];
175
+    }
176
+    localNote.repeatInterval = NSCalendarUnitMonth;
177
+    localNote.alertBody = [NSString stringWithFormat:@"%@%@啦",card.bill_account,name];
178
+    localNote.soundName = UILocalNotificationDefaultSoundName;
179
+    localNote.applicationIconBadgeNumber = [UIApplication sharedApplication].applicationIconBadgeNumber+1;
180
+    localNote.userInfo = @{@"name":name,@"limit":limit};
181
+    [[UIApplication sharedApplication] scheduleLocalNotification:localNote];
182
+}
183
+
184
+@end

+ 2 - 2
KXCardHelp/Tools/WWValuePickerView/WWValuePickerView.m

@@ -128,7 +128,7 @@
128 128
     }
129 129
     
130 130
     //设置返回默认值
131
-    self.stateStr = [NSString stringWithFormat:@"%@/%@",_dataSource[0],@(1)];
131
+    self.stateStr = [NSString stringWithFormat:@"%@/%@",_dataSource[0],@(0)];
132 132
     
133 133
     //刷新布局
134 134
     [self layoutSelfSubviews];
@@ -179,7 +179,7 @@
179 179
 
180 180
 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
181 181
 {
182
-    self.stateStr = [NSString stringWithFormat:@"%@/%@",self.dataSource[row], @(row + 1)];
182
+    self.stateStr = [NSString stringWithFormat:@"%@/%@",self.dataSource[row], @(row)];
183 183
 }
184 184
 
185 185
 #pragma mark - 按钮相关

+ 84 - 0
Pods/Pods.xcodeproj/xcuserdata/xiaoxi.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -0,0 +1,84 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+	<key>SchemeUserState</key>
6
+	<dict>
7
+		<key>AFNetworking.xcscheme</key>
8
+		<dict>
9
+			<key>orderHint</key>
10
+			<integer>1</integer>
11
+		</dict>
12
+		<key>FLAnimatedImage.xcscheme</key>
13
+		<dict>
14
+			<key>orderHint</key>
15
+			<integer>2</integer>
16
+		</dict>
17
+		<key>FMDB.xcscheme</key>
18
+		<dict>
19
+			<key>orderHint</key>
20
+			<integer>3</integer>
21
+		</dict>
22
+		<key>IQKeyboardManager.xcscheme</key>
23
+		<dict>
24
+			<key>orderHint</key>
25
+			<integer>4</integer>
26
+		</dict>
27
+		<key>MBProgressHUD.xcscheme</key>
28
+		<dict>
29
+			<key>orderHint</key>
30
+			<integer>6</integer>
31
+		</dict>
32
+		<key>MJExtension.xcscheme</key>
33
+		<dict>
34
+			<key>orderHint</key>
35
+			<integer>7</integer>
36
+		</dict>
37
+		<key>MJRefresh.xcscheme</key>
38
+		<dict>
39
+			<key>orderHint</key>
40
+			<integer>8</integer>
41
+		</dict>
42
+		<key>Masonry.xcscheme</key>
43
+		<dict>
44
+			<key>orderHint</key>
45
+			<integer>5</integer>
46
+		</dict>
47
+		<key>PPBadgeView.xcscheme</key>
48
+		<dict>
49
+			<key>orderHint</key>
50
+			<integer>10</integer>
51
+		</dict>
52
+		<key>Pods-KXCardHelp.xcscheme</key>
53
+		<dict>
54
+			<key>orderHint</key>
55
+			<integer>9</integer>
56
+		</dict>
57
+		<key>ReactiveCocoa.xcscheme</key>
58
+		<dict>
59
+			<key>orderHint</key>
60
+			<integer>11</integer>
61
+		</dict>
62
+		<key>SDWebImage.xcscheme</key>
63
+		<dict>
64
+			<key>orderHint</key>
65
+			<integer>12</integer>
66
+		</dict>
67
+		<key>XHLaunchAd.xcscheme</key>
68
+		<dict>
69
+			<key>orderHint</key>
70
+			<integer>13</integer>
71
+		</dict>
72
+		<key>YYCategories.xcscheme</key>
73
+		<dict>
74
+			<key>orderHint</key>
75
+			<integer>14</integer>
76
+		</dict>
77
+		<key>YYModel.xcscheme</key>
78
+		<dict>
79
+			<key>orderHint</key>
80
+			<integer>15</integer>
81
+		</dict>
82
+	</dict>
83
+</dict>
84
+</plist>