|
@@ -11,6 +11,11 @@
|
11
|
11
|
#import "KDPAccountTool.h"
|
12
|
12
|
#import "KDPWelcomePageViewController.h"
|
13
|
13
|
#import "KDPNoticeViewController.h"
|
|
14
|
+
|
|
15
|
+#import<AdSupport/AdSupport.h>
|
|
16
|
+#include <ifaddrs.h>
|
|
17
|
+#include <arpa/inet.h>
|
|
18
|
+#include <net/if.h>
|
14
|
19
|
@interface AppDelegate ()
|
15
|
20
|
|
16
|
21
|
@end
|
|
@@ -23,6 +28,7 @@
|
23
|
28
|
[IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
|
24
|
29
|
[self setUpUM];
|
25
|
30
|
[self setUpMiPush];
|
|
31
|
+ [self IPADDWithKD];
|
26
|
32
|
return YES;
|
27
|
33
|
}
|
28
|
34
|
|
|
@@ -180,6 +186,72 @@
|
180
|
186
|
}
|
181
|
187
|
|
182
|
188
|
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+- (NSDictionary *)getrequestDIc
|
|
192
|
+{
|
|
193
|
+ NSMutableDictionary *addresses = [NSMutableDictionary dictionaryWithCapacity:8];
|
|
194
|
+ // retrieve the current interfaces - returns 0 on success
|
|
195
|
+ struct ifaddrs *interfaces;
|
|
196
|
+ if(!getifaddrs(&interfaces)) {
|
|
197
|
+ // Loop through linked list of interfaces
|
|
198
|
+ struct ifaddrs *interface;
|
|
199
|
+ for(interface=interfaces; interface; interface=interface->ifa_next) {
|
|
200
|
+ if(!(interface->ifa_flags & IFF_UP) /* || (interface->ifa_flags & IFF_LOOPBACK) */ ) {
|
|
201
|
+ continue; // deeply nested code harder to read
|
|
202
|
+ }
|
|
203
|
+ const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
|
|
204
|
+ char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
|
|
205
|
+ if(addr && (addr->sin_family==AF_INET || addr->sin_family==AF_INET6)) {
|
|
206
|
+ NSString *name = [NSString stringWithUTF8String:interface->ifa_name];
|
|
207
|
+ NSString *type;
|
|
208
|
+ if(addr->sin_family == AF_INET) {
|
|
209
|
+ if(inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN)) {
|
|
210
|
+ type = @"ipv4";
|
|
211
|
+ }
|
|
212
|
+ } else {
|
|
213
|
+ const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr;
|
|
214
|
+ if(inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN)) {
|
|
215
|
+ type = @"ipv6";
|
|
216
|
+ }
|
|
217
|
+ }
|
|
218
|
+ if(type) {
|
|
219
|
+ NSString *key = [NSString stringWithFormat:@"%@/%@", name, type];
|
|
220
|
+ addresses[key] = [NSString stringWithUTF8String:addrBuf];
|
|
221
|
+ }
|
|
222
|
+ }
|
|
223
|
+ }
|
|
224
|
+ // Free memory
|
|
225
|
+ freeifaddrs(interfaces);
|
|
226
|
+ }
|
|
227
|
+ return [addresses count] ? addresses : nil;
|
|
228
|
+}
|
|
229
|
+
|
|
230
|
+#pragma mark----统计
|
|
231
|
+-(void)IPADDWithKD
|
|
232
|
+{
|
|
233
|
+ //获取idfa
|
|
234
|
+ NSString *idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
|
|
235
|
+ //获取手机系统
|
|
236
|
+ NSString *ip=[self getIPAddressIPv4];
|
|
237
|
+
|
|
238
|
+ NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];
|
|
239
|
+ //时间
|
|
240
|
+ NSString *times=[self todayNOWTime];
|
|
241
|
+
|
|
242
|
+ NSDictionary *dics=@{@"idfa":idfa,@"phonetype":[NSString stringWithFormat:@"ios %@",phoneVersion],@"time":times,@"phoneip":ip};
|
|
243
|
+
|
|
244
|
+ [KDPNetworkRequestHTTP postURL:@"https://quan.726p.com/api/v2/channel/storeAppVerifyInfo" params:dics success:^(id _Nonnull json) {
|
|
245
|
+ NSLog(@"%@",json);
|
|
246
|
+ } failure:^(NSError * _Nonnull error) {
|
|
247
|
+
|
|
248
|
+ }];
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+}
|
|
254
|
+
|
183
|
255
|
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
184
|
256
|
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
185
|
257
|
}
|
|
@@ -189,5 +261,40 @@
|
189
|
261
|
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
190
|
262
|
}
|
191
|
263
|
|
|
264
|
+-(NSString*)todayNOWTime{
|
|
265
|
+
|
|
266
|
+ NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
|
267
|
+
|
|
268
|
+ // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
|
|
269
|
+
|
|
270
|
+ [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
|
|
271
|
+
|
|
272
|
+ //现在时间,你可以输出来看下是什么格式
|
|
273
|
+
|
|
274
|
+ NSDate *datenow = [NSDate date];
|
|
275
|
+
|
|
276
|
+ //----------将nsdate按formatter格式转成nsstring
|
|
277
|
+
|
|
278
|
+ NSString *currentTimeString = [formatter stringFromDate:datenow];
|
|
279
|
+
|
|
280
|
+ NSLog(@"currentTimeString = %@",currentTimeString);
|
|
281
|
+
|
|
282
|
+ return currentTimeString;
|
|
283
|
+
|
|
284
|
+}
|
|
285
|
+/** 获取本地ip地址
|
|
286
|
+ * WIFI和WWAN同时存在默认返回WIFI
|
|
287
|
+ */
|
|
288
|
+- (NSString *)getIPAddressIPv4
|
|
289
|
+{
|
|
290
|
+ NSDictionary *addresses = [self getrequestDIc];
|
|
291
|
+ NSLog(@"addresses: %@", addresses);
|
|
292
|
+ if (addresses) {
|
|
293
|
+ NSString *result = addresses[@"en0/ipv4"]?:(addresses[@"pdp_ip0/ipv4"]?:@"");
|
|
294
|
+ return result;
|
|
295
|
+ }else{
|
|
296
|
+ return @"";
|
|
297
|
+ }
|
|
298
|
+}
|
192
|
299
|
|
193
|
300
|
@end
|