Here is the code I use to generate the airshipConfigOptions
for three of my targets. The targets have macros in the build settings for each target: {TARGET_A, TARGET_B, TARGET_C}:
- (void)urbanAirshipTakeoffWithLaunchOptions:(NSDictionary *)launchOptions {
// Init Airship launch options
NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Build the Urban Airship TakeOffOptions
// Create Airship singleton that's used to talk to Urban Airship servers.
// Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
NSMutableDictionary *airshipConfigOptions = [[NSMutableDictionary alloc] init];
/*
* Set up the Push keys based on target
*/
_uaApp = @"unknown";
// iFlightBag TARGET_A
#ifdef TARGET_A
NSLog(@"Appdelegate_Pad:didFinishLaunchingWithOptions - TARGET_A");
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_SECRET"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_SECRET"];
_uaApp = "@TARGET_A";
#endif
// iFlightBag TARGET_B
#ifdef TARGET_B
NSLog(@"Appdelegate_Pad:didFinishLaunchingWithOptions - TARGET_B");
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_SECRET"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_SECRET"];
_uaApp = @"TARGET_B";
#endif
// iFlightBag
#ifdef TARGET_C
NSLog(@"Appdelegate_Pad:didFinishLaunchingWithOptions - TARGET_C");
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_SECRET"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_SECRET"];
_uaApp = @"TARGET_C";
#endif
// If CONFIGURATION_Debug is defined, then use the development servers, else use the production servers
#ifdef CONFIGURATION_Debug
[airshipConfigOptions setValue:@"NO" forKey:@"APP_STORE_OR_AD_HOC_BUILD"];
NSLog(@"Using Development Servers at Urban Airship");
_uaApp = [_uaApp stringByAppendingString:@"_dev"];
#else
[airshipConfigOptions setValue:@"YES" forKey:@"APP_STORE_OR_AD_HOC_BUILD"];
NSLog(@"Using Production Servers at Urban Airship");
#endif
// Erase stored user informaton - set in settings?
if(self.getEraseUser) [airshipConfigOptions setValue:@"YES" forKey:@"DELETE_KEYCHAIN_CREDENTIALS"];
// Set and start Urban Airship
[takeOffOptions setValue:airshipConfigOptions forKey:UAirshipTakeOffOptionsAirshipConfigKey];
[UAirship takeOff:takeOffOptions];
// -----
// Set up Urban Airship Inbox
// Set up the list and message view controllers for the master and detail panels, respectively.
// If the application gets an UAInbox message id on launch open it up immediately. Only works for the default inbox
//Init the UI
[UAInbox useCustomUI:[UAInboxUI class]];//sample UI implementation
[UAInbox shared].pushHandler.delegate = [UAInboxUI shared];
// If the application gets an UAInbox message id on launch open it up immediately.
// Only works for the default inbox
[UAInboxUI shared].inboxParentController = self.tabcontroller;
[UAInboxPushHandler handleLaunchOptions:launchOptions];
if ([[UAInbox shared].pushHandler hasLaunchMessage]) {
[[[UAInbox shared] uiClass] loadLaunchMessage];
}
// Register for notifications
[[UAPush shared] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
}