2012-03-28 4 views
1

Ich versuche, Push-Benachrichtigungen in meiner App zu implementieren. Also habe ich zum Testen eine neue App aufgebaut und alle notwendigen Schritte gemacht (ich hoffe ...). Ich fügte meinem Projekt Folgendes hinzu:Geräte-Token inkorrekt mit Urban Airship?

-AirshipConfig.plist 
-libUAirship-1.1.4.a 
-UAGLobal. 
-UAirship.h 
-UAObservable.h 
-UAPush.h 

und alle auf ihrer Website aufgeführten Frameworks.

Mein AppDelegate.m ist:

#import "AppDelegate.h" 
#import "UAirship.h" 
#import "UAPush.h" 

@implementation AppDelegate 

@synthesize window = _window; 

-(void)setupPushWithOptions:(NSDictionary *)launchOptions { 


//URBAN AIRSHIP PUSH NOTIFICATION CONFIGURATION 
//Init Airship launch options 
NSMutableDictionary *airshipConfigOptions = [[NSMutableDictionary alloc] init]; 
//[airshipConfigOptions setValue:@"5QQmJyTMRZWks0nbx-9pHQ" forKey:@"DEVELOPMENT_APP_KEY"]; 
//[airshipConfigOptions setValue:@"OMuzzHdCQOCnrOtfiWox9Q" 
forKey:@"DEVELOPMENT_APP_SECRET"]; 
[airshipConfigOptions setValue:@"xrUoy0B1RdyjZqZXEuwIsg" forKey:@"PRODUCTION_APP_KEY"]; 
[airshipConfigOptions setValue:@"qiRlUvoaSHGNeXxw9pj71w" forKey:@"PRODUCTION_APP_SECRET"]; 

#ifdef DEBUG 
[airshipConfigOptions setValue:@"NO" forKey:@"APP_STORE_OR_AD_HOC_BUILD"]; 
#else 
[airshipConfigOptions setValue:@"YES" forKey:@"APP_STORE_OR_AD_HOC_BUILD"]; 
#endif 

NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init]; 
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey]; 
[takeOffOptions setValue:airshipConfigOptions 
forKey:UAirshipTakeOffOptionsAirshipConfigKey];  

// 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]; 

[[UAPush shared] resetBadge];//zero badge on startup  
[[UAPush shared] 
registerForRemoteNotificationTypes:UIRemoteNotificationTypeNewsstandContentAvailability|UIRemoteNotificationTypeAlert]; // register for Newsstand and Alerts 

} 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: 
(NSDictionary *)launchOptions 
{ 
// Override point for customization after application launch. 
//Init Airship launch options 
NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init]; 
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey]; 

// Create Airship singleton that's used to talk to Urban Airship servers. 
// Please populate AirshipConfig.plist with your info from http://go.urbanairship.com 
[UAirship takeOff:takeOffOptions]; 
[[UIApplication sharedApplication] 
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | 
            UIRemoteNotificationTypeSound | 
            UIRemoteNotificationTypeAlert)]; 
// Override point for customization after application launch. 

[self setupPushWithOptions:launchOptions]; 
return YES; 
} 

- (void)application:(UIApplication *)application 
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
UALOG(@"APN device token: %@", deviceToken); 
NSLog(@"%@", deviceToken); 
// Updates the device token and registers the token with UA 
[[UAirship shared] registerDeviceToken:deviceToken]; 
} 

- (void)applicationWillResignActive:(UIApplication *)application 
{ 
} 

- (void)applicationDidEnterBackground:(UIApplication *)application 
{ 
} 

- (void)applicationWillEnterForeground:(UIApplication *)application 
{ 
} 

- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
} 

- (void)applicationWillTerminate:(UIApplication *)application 
{ 
} 

-(void)application:(UIApplication *)application 
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { 
NSLog(@"Failing in APNS registration: %@",error); 
} 

@end 

Auf diese Weise ich die Fehler Apple Push Service Gerät Token abgelehnt bekommen Aber ich auch, dass mein Gerät Token nicht korrekt sein könnte abgerufen herausgefunden. Nach einem UA-Mitarbeiter-Vorschlag habe ich aus dem Appstore die App Weitwinkel heruntergeladen, und ich startete sie mit meinem iPhone verbunden und mit der offenen Xcode-Konsole. Also kann ich sehen, dass mein Geräte-Token ein anderer ist ... Wo könnte das Problem sein?

Antwort

0

Sie sollten Ihre Variablen nicht in Urban Airship wie folgt fest codieren.

erstellen AirshipConfig.plist Die Bibliothek verwendet einen .plist Konfiguration Datei mit dem Namen AirshipConfig.plist Ihre Produktion und Entwicklung Anwendungsprofile zu verwalten.

Erstellen Sie 2 Anwendungen in Ihrem Urban Airship-Konto - eins für Entwicklung & ein anderes für die Produktion. Ex. Name_of_your_app_dev Name_of_your_app_prod eine AirshipConfig.plist Datei Erstellen Sie die folgende Werte zu den in Ihren Anwendungen Set