This repository has been archived by the owner on Oct 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotificationPoller.m
54 lines (44 loc) · 1.71 KB
/
NotificationPoller.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// NotificationPoller.m
// Honeypot
//
// Created by Andrew Arnopoulos on 11/15/14.
// Copyright (c) 2014 Andrew Arnopoulos. All rights reserved.
//
#import "NotificationPoller.h"
#import <UIKit/UIKit.h>
#import "Wallet.h"
@implementation NotificationPoller
+(NotificationPoller *) sharedInstance {
static NotificationPoller * singleton = nil;
if (!singleton) {
singleton = [[NotificationPoller alloc] init];
}
return singleton;
}
-(void)startPolling:(int)timeInterval {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSDictionary * oldDictionary = [Wallet getWallets];
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings * settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
while(true) {
NSDictionary * walletDictionary = [Wallet getWallets];
for (id key in oldDictionary) {
NSLog(@"%i",[walletDictionary[key] compromised]);
if ([walletDictionary[key] compromised] && [oldDictionary[key] compromised] != true) {
UILocalNotification * notification = [[UILocalNotification alloc] init];
notification.fireDate = [NSDate date];
notification.alertBody = @"One of your wallets have been compromised. Act quickly to prevent further repercussions!";
notification.soundName = UILocalNotificationDefaultSoundName;
// notification.applicationIconBadgeNumber
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
break;
}
}
oldDictionary = walletDictionary;
sleep(timeInterval);
}
});
}
@end