Skip to content

Instantly share code, notes, and snippets.

View Kevinwlee's full-sized avatar

Kevin Lee Kevinwlee

View GitHub Profile
- (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] 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 withCompletion:^(NSError *error) {
if(error) {
NSLog(@"%@", error);
} else {
NSLog(@"Success :)");
}
NSDictionary *userInfo = @{ @"alert":self.messageField.text};
[[CCHNotificationService sharedService] sendAPNSNotificationToDevices:@[@"longdevicetokenhere", @"anotherlongdevicetokenhere"] userInfo:userInfo withCompletion:^(NSError *error) {
NSLog(@"Error %@", error);
}];
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Register your app
[ContextHub registerWithAppId:@"823b8648-YOUR-UUID-a653-748d4fff9128"];
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound ];
return YES;
}
openssl pkcs12 -in Certificates.p12 -out certificate.pem -nodes -clcerts
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[ContextHub application:application didReceiveRemoteNotification:userInfo completion:completionHandler];
}
@Kevinwlee
Kevinwlee / did post event
Last active August 29, 2015 13:57
CCHContextEventManagerDelegate
#pragma mark - CCHContextEventManagerDelegate
- (void)contextEventManager:(CCHContextEventManager *)eventManager didPostEvent:(NSDictionary *)event {
NSLog(@"DID Post Event %@", event);
}
@Kevinwlee
Kevinwlee / will post event
Last active August 29, 2015 13:57
CCHContextEventManagerDelegate
#pragma mark - CCHContextEventManagerDelegate
- (void)contextEventManager:(CCHContextEventManager *)eventManager willPostEvent:(NSDictionary *)event {
NSLog(@"WILL Post Event %@", event);
}
@Kevinwlee
Kevinwlee / CCHContextEventManagerDataSource
Created March 27, 2014 14:27
Sample of how to return data.
#pragma mark - CCHContextEventManagerDataSource
- (NSDictionary *)contextEventManager:(CCHContextEventManager *)eventManager payloadForEvent:(NSDictionary *)event {
return @{@"company":@"ChaiONE", @"project":@"ContextHub"};
}