Skip to content

Instantly share code, notes, and snippets.

View Kevinwlee's full-sized avatar

Kevin Lee Kevinwlee

View GitHub Profile
openssl pkcs12 -in Certificates.p12 -out certificate.pem -nodes -clcerts
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Register your app
[ContextHub registerWithAppId:@"823b8648-YOUR-UUID-a653-748d4fff9128"];
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound ];
return YES;
}
NSDictionary *userInfo = @{ @"alert":self.messageField.text};
[[CCHNotificationService sharedService] sendAPNSNotificationToDevices:@[@"longdevicetokenhere", @"anotherlongdevicetokenhere"] userInfo:userInfo withCompletion:^(NSError *error) {
NSLog(@"Error %@", error);
}];
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
CCHNotificationService *sharedService = [CCHNotificationService sharedService];
NSString *deviceID = [ContextHub deviceId];
[sharedService registerDeviceToken:deviceToken withAlias:deviceID withCompletion:^(NSError *error) {
if(error) {
NSLog(@"%@", error);
} else {
NSLog(@"Success :)");
}
NSDictionary *userInfo = @{ @"alert":self.messageField.text};
[[CCHNotificationService sharedService] sendAPNSNotificationToAliases:@[[ContextHub deviceId]] userInfo:userInfo withCompletion:^(NSError *error) {
NSLog(@"Error %@", error);
}];
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
CCHNotificationService *sharedService = [CCHNotificationService sharedService];
NSString *deviceID = [ContextHub deviceId];
[sharedService registerDeviceToken:deviceToken
withAlias:deviceID
andTags:@[@"tag1", @"tag2"]
withCompletion:^(NSError *error) {
if(error) {
NSLog(@"%@", error);
} else {
NSDictionary *userInfo = @{ @"alert":self.messageField.text};
[[CCHNotificationService sharedService] sendAPNSNotificationToTags:@[@"tag1"] userInfo:userInfo withCompletion:^(NSError *error) {
NSLog(@"Error %@", error);
}];
NSDictionary *userInfo = @{@"custom":self.customData.text, @"alert":@"Data was pushed!"};
[[CCHNotificationService sharedService] sendAPNSNotificationToAliases:@[[ContextHub deviceId]] userInfo:userInfo withCompletion:^(NSError *error) {
NSLog(@"Error %@", error);
}];
NSDictionary *userInfo = @{@"sound":@"techno.aif", @"custom":self.customData.text, @"alert":@"CAN YOU HEAR ME NOW?", @"badge":@"1000"};
[[CCHNotificationService sharedService] sendAPNSNotificationToAliases:@[[ContextHub deviceId]] userInfo:userInfo withCompletion:^(NSError *error) {
NSLog(@"Error %@", error);
}];
NSDictionary *userInfo = @{@"content-available":@"1", @"sound":@"", @"custom":self.customData.text, @"alert":@""};
[[CCHNotificationService sharedService] sendAPNSNotificationToAliases:@[[ContextHub deviceId]] userInfo:userInfo withCompletion:^(NSError *error) {
NSLog(@"Error %@", error);
}];