MCO
MCO

Reputation: 163

Push Notifications using Urban Airship correctly

I tried using Urban Airship for sending push notifications to the devices. I register the device to push using: Code:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

I created an app on Urban Airship, uploaded the certificate key and tried sending a broadcast with no success. Only when I manually added the device token to Urban Airship, I successfully sent and got a broadcast. My question is - can I use Urban Airship to send Push notifications without registering device tokens and how? If not, how do I register the device tokens automatically from the app (and not using the curl code)? Is there any other push provider which doesn't require more than Apple's basic registerForRemoteNotificationTypes: method?

Thanks!

Upvotes: 1

Views: 1251

Answers (1)

WrightsCS
WrightsCS

Reputation: 50727

No, Urban Airhip cannot send push notifications if the device does not register on the network, think about that logic. registerForRemoteNotificationTypes: simply initiates the registration process and assumes you have done the rest of the leg work to make that magic happen.

You also need the rest of the delegates to properly register and receive Push Notifications on your device.

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)_deviceToken;

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error;

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;

In addition to these UIApplication delegates, you need to initiate the Airship classes by doing the following in your didFinishLaunchingWithOptions: delegate:

[Airship takeOff: kApplicationKey identifiedBy: kApplicationSecret];

Upvotes: 3

Related Questions