sigma
sigma

Reputation: 117

Distinguish between distribution and development for apple push notificiations

When I start the app, it registers for push notifications and depending on the provisioning profile it will generate a different push token.

Since both AdHoc and AppStore provisioning profiles connect to the same server, I have to somehow distinguish what kind of token it is, so that the server can connect to the right apple server. (sandbox/production)

How can achieve that?

Upvotes: 0

Views: 61

Answers (1)

Aaron Wojnowski
Aaron Wojnowski

Reputation: 6480

I believe the best way to achieve this would be to make the development/production distinction when you send the token to the server, and have your server annotate the type of token in the database.

Surely you have some sort of API call to your server which is passing in the token. In that call, pass in the type of token as well. Ex:

{ "token" : "abcd....", "type" : "development" }

To actually make the distinction at build time, you can use preprocessor directives to detect whether it's a debug build, release build, or an App Store build.

Checking if debug is enabled is easy, but to make a distinction about whether it's AdHoc or App Store, consider creating a user defined variable. To do this, clone the Release scheme and create one called App Store. Then in your Build Settings, go to user defined variables and create one called APP_STORE, but only for the App Store scheme. When you release to the store, make sure that you build using that scheme instead of Release when you archive.

Then, checking the type to pass into your API is as easy as doing this:

NSString *type = nil;
#ifdef DEBUG
    type = @"debug";
#elseif APP_STORE
    type = @"app_store";
#else
    type = @"release";
#endif

Upvotes: 1

Related Questions