Last active
August 29, 2015 14:13
-
-
Save snatchev/0390b91c341051f466dc to your computer and use it in GitHub Desktop.
register VoIP push notifications with ZeroPush: https://zeropush.com/guide/guide-to-pushkit-and-voip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <PushKit/PushKit.h> | |
@interface AppDelegate : UIResponder <UIApplicationDelegate, PKPushRegistryDelegate> | |
@property (strong, nonatomic) UIWindow *window; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ZeroPush.h" | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
PKPushRegistry * voipRegistry = [[PKPushRegistry alloc] initWithQueue: dispatch_get_main_queue()]; | |
voipRegistry.delegate = self; | |
voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; | |
} | |
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type { | |
[[ZeroPush shared] registerDeviceToken:credentials.token]; | |
} | |
-(void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type | |
{ | |
UILocalNotification *notification = [[UILocalNotification alloc] init]; | |
NSDictionary *data = [payload.dictionaryPayload objectForKey:@"aps"]; | |
notification.alertBody = [data objectForKey:@"alert"]; | |
notification.category = [data objectForKey:@"category"]; | |
[[UIApplication sharedApplication] presentLocalNotificationNow:notification]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment