Discussion Forums  >  Uncategorized

Replies: 6    Views: 760

MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
09/01/11 09:38 AM (14 years ago)

Any Xcode gurus who can help me with a custom plugin issue?

I've successfully integrated Rich Push notifications from Urban Airship into an app. They provide sample inbox code, which I have placed into my BT_Plugins folder. I use a right navigation button to launch the custom plugin. All works perfectly well except for one issue. Their sample code launches a screen with a button that you need to click to launch the actual inbox. Screenshots: http://www.jc-evans.com/images/Screen-shot1.png http://www.jc-evans.com/images/Screen-shot2.png I'd like to bypass that initial screen and have my nav button launch the inbox, but I've had no luck changing the coding. I have been successful in crashing or locking up the app, though. LOL Anyone want to have a look and give me some advice? I can send you the ViewController.h & .m files. You can email me directly at [email protected] too. Thanks.
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
09/01/11 10:02 AM (14 years ago)
Hi there MGoBlue, I'm actually one step behind, still trying to integrate Rich Push from Urban Airship. Do you have any info (or tutorials) to help me with that? I've succesfully integrated appoxee with my apps, and it works fine, the problem is that they're not open for new accounts. Also, have you tried asking their support staff? Even though they didn't solve my issue they responded very quickly and gave me a lot of tips and insight.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
09/01/11 10:48 AM (14 years ago)
I have a request into their support staff too. They have been pretty good about getting back to me, but both times I'd already figured out the problem. I will probably put a tutorial together. It's a bit complicated, but basically, what you need to do is: Copy the Airship folder in xcode Copy the 'Classes' and 'Resources' folders from their sample into your BT_Plugins folder Add the following to your appDelegate.m file: #import UAirship.h #import UAInbox.h #import UAInboxUI.h #import InboxSampleViewController.h #import UAInboxDefaultJSDelegate.h Add the following to your appDelegate.h #import UAirship.h #import UAInbox.h Add the following to your appDelegate.m directly under didFinishLaunchingwithOptions: //Init Airship launch options NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease]; [takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey]; // To use your own pre-existing inbox credentials, uncomment and modify these lines: //[takeOffOptions setValue:@4cf54407a9ee256d9400000c forKey:UAAirshipTakeOffOptionsDefaultUsername];//username //[takeOffOptions setValue:@GUvTvih4RcaqZZOAsLvKXQ forKey:UAAirshipTakeOffOptionsDefaultPassword];//password // Create Airship singleton that's used to talk to Urban Airship servers. // Please replace these with your info from http://go.urbanairship.com [UAirship takeOff:takeOffOptions]; //Init the UI [UAInbox useCustomUI:[UAInboxUI class]];//sample UI implementation // If the application gets an UAInbox message id on launch open it up immediately. // Only works for the default inbox [UAInboxUI shared].inboxParentController = viewController; [UAInboxPushHandler handleLaunchOptions:launchOptions]; if ([[UAInbox shared].pushHandler hasLaunchMessage]) { [UAInboxUI loadLaunchMessage]; } // Register for notifications [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; [UAInboxPushHandler handleLaunchOptions:launchOptions]; Then after that section (after the closing '}') add: - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { // Updates the device token and registers the token with UA [[UAirship shared] registerDeviceToken:deviceToken]; } - (void)applicationWillTerminate:(UIApplication *)application { [UAirship land]; } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [UAInboxPushHandler handleNotification:userInfo forInbox:[UAInboxMessageList defaultInbox]]; } There are a few more steps. As you compile it, you'll find some errors. A couple duplicate files that need to be deleted, etc. Hope this helps. I've actually got it running in two apps now.
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
09/01/11 11:46 AM (14 years ago)
Thanks MGoBlue! I'll try that, it doesn't seem very different from appoxee. ----------------------------------------- The problem with the inbox view might be related to something on this part of the code... //Init the UI [UAInbox useCustomUI:[UAInboxUI class]];//sample UI implementation // If the application gets an UAInbox message id on launch open it up immediately. <-------------- // Only works for the default inbox [UAInboxUI shared].inboxParentController = viewController; [UAInboxPushHandler handleLaunchOptions:launchOptions]; if ([[UAInbox shared].pushHandler hasLaunchMessage]) { [UAInboxUI loadLaunchMessage]; } It seems there's a message ID that you can set when sending the Push that will make the app go straight to that specific message. Have you tried it? Also, I took a look at their documentation and found this regarding the inbox. Here's what I found: http://urbanairship.com/docs/richpush_client.html#launch-rich-push-to-an-inbox Launch Rich Push to an inbox Displaying the inbox is as simple as making a single call and passing in the view controller from which you wish to launch the Inbox UI. [UAInbox displayInbox:parentViewController animated:YES]; Opening incoming push notifications You can send along Push notifications along with your Rich Push. These notifications will be associated with an Rich Push Inbox ID and on receipt the user can choose to ‘View’ the message. In this case we allow you to check for the incoming ID and view the message directly. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [UAInboxPushHandler handleLaunchOptions:launchOptions]; ... } If you would like to show notifications received while the app is running, add the following to your app delegate: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [UAInboxPushHandler handleNotification:userInfo forInbox:[UAInboxMessageList defaultInbox]]; } I dont think that will solve the problem of the first screenshot you showed in your post, but it seems that this will take the user directly to the rich message, avoiding that particular screen.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
09/01/11 12:03 PM (14 years ago)
Thanks. The Rich Push is really cool, and yes, it does open directly into the inbox message. That part's not the problem. I've been trying to figure a way to execute the code you referenced - [UAInbox displayInbox:parentViewController animated:YES]; That, I think would bypass the other screen. Just haven't figured a way past it.
 
ThomasB
Lost but trying
Profile
Posts: 162
Reg: Jun 23, 2011
Palo Alto
3,270
like
09/05/11 09:50 AM (14 years ago)
Really interested thread. We're in the process of trying to implement a different (healthcare-specific) push notification tool and running into a very similar set of problems :) Ack. @MGo did you ever figure it out? I think you may end up being the Xcode guru after these experiences!
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
09/21/11 03:42 PM (14 years ago)
I ended up using their page, just modifying the look to match my app. I also used the page to explain what the inbox was. I'll keep working on figuring it out. Just have so many varied projects right now, that I keep getting pulled away from this.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.