Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EFCFC10818 for ; Mon, 24 Mar 2014 21:22:33 +0000 (UTC) Received: (qmail 67738 invoked by uid 500); 24 Mar 2014 21:22:33 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 67704 invoked by uid 500); 24 Mar 2014 21:22:33 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 67695 invoked by uid 99); 24 Mar 2014 21:22:33 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Mar 2014 21:22:33 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C29828B5C87; Mon, 24 Mar 2014 21:22:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shazron@apache.org To: commits@cordova.apache.org Message-Id: <8809691f68ed4e309e6b03202c2f019a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ios commit: CB-6340 - Adding rebroadcast capabilities to remote notification registration within AppDelegate (closes #94) Date: Mon, 24 Mar 2014 21:22:32 +0000 (UTC) Repository: cordova-ios Updated Branches: refs/heads/master 0fd957a55 -> b29695849 CB-6340 - Adding rebroadcast capabilities to remote notification registration within AppDelegate (closes #94) Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/b2969584 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/b2969584 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/b2969584 Branch: refs/heads/master Commit: b296958497c55314e6a54bd0d53c6935bd16940f Parents: 0fd957a Author: Sushant Verma Authored: Wed Mar 12 11:47:35 2014 +1100 Committer: Shazron Abdullah Committed: Mon Mar 24 14:21:45 2014 -0700 ---------------------------------------------------------------------- CordovaLib/Classes/CDVPlugin.h | 2 ++ CordovaLib/Classes/CDVPlugin.m | 2 ++ .../__PROJECT_NAME__/Classes/AppDelegate.m | 21 +++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b2969584/CordovaLib/Classes/CDVPlugin.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h index 33ba1c4..3def31e 100644 --- a/CordovaLib/Classes/CDVPlugin.h +++ b/CordovaLib/Classes/CDVPlugin.h @@ -27,6 +27,8 @@ extern NSString* const CDVPageDidLoadNotification; extern NSString* const CDVPluginHandleOpenURLNotification; extern NSString* const CDVPluginResetNotification; extern NSString* const CDVLocalNotification; +extern NSString* const CDVRemoteNotification; +extern NSString* const CDVRemoteNotificationError; @interface CDVPlugin : NSObject {} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b2969584/CordovaLib/Classes/CDVPlugin.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m index 8c932a0..ea81ddd 100644 --- a/CordovaLib/Classes/CDVPlugin.m +++ b/CordovaLib/Classes/CDVPlugin.m @@ -23,6 +23,8 @@ NSString* const CDVPageDidLoadNotification = @"CDVPageDidLoadNotification"; NSString* const CDVPluginHandleOpenURLNotification = @"CDVPluginHandleOpenURLNotification"; NSString* const CDVPluginResetNotification = @"CDVPluginResetNotification"; NSString* const CDVLocalNotification = @"CDVLocalNotification"; +NSString* const CDVRemoteNotification = @"CDVRemoteNotification"; +NSString* const CDVRemoteNotificationError = @"CDVRemoteNotificationError"; @interface CDVPlugin () http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b2969584/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m ---------------------------------------------------------------------- diff --git a/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m b/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m index 377225f..cc82260 100644 --- a/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m +++ b/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m @@ -109,7 +109,7 @@ return YES; } -// repost the localnotification using the default NSNotificationCenter so multiple plugins may respond +// repost all remote and local notification using the default NSNotificationCenter so multiple plugins may respond - (void) application:(UIApplication*)application didReceiveLocalNotification:(UILocalNotification*)notification { @@ -117,6 +117,25 @@ [[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification]; } +- (void) application:(UIApplication *)application + didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken +{ + // re-post ( broadcast ) + NSString* token = [[[[deviceToken description] + stringByReplacingOccurrencesOfString: @"<" withString: @""] + stringByReplacingOccurrencesOfString: @">" withString: @""] + stringByReplacingOccurrencesOfString: @" " withString: @""]; + + [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotification object:token]; +} + +- (void) application:(UIApplication *)application + didFailToRegisterForRemoteNotificationsWithError:(NSError *)error +{ + // re-post ( broadcast ) + [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotificationError object:error]; +} + - (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window { // iPhone doesn't support upside down by default, while the iPad does. Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected).