-
Notifications
You must be signed in to change notification settings - Fork 24
/
AppDelegate.m
31 lines (22 loc) · 1.11 KB
/
AppDelegate.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
#import "AppDelegate.h"
@import PushNotifications;
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[PushNotifications shared] startWithInstanceId:@"YOUR_INSTANCE_ID"]; // Can be found here: https://dash.pusher.com
[[PushNotifications shared] registerForRemoteNotifications];
NSError *anyError;
[[PushNotifications shared] addDeviceInterestWithInterest:@"debug-test" error:&anyError];
}
- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[PushNotifications shared] registerDeviceToken:deviceToken];
}
- (void)application:(NSApplication *)application didReceiveRemoteNotification:(NSDictionary<NSString *,id> *)userInfo {
[[PushNotifications shared] handleNotificationWithUserInfo:userInfo];
NSLog(@"%@", userInfo);
}
- (void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"Remote notification support is unavailable due to error: %@", error.localizedDescription);
}
@end