Reputation: 1869
I'm following this tutorial for creating my first push notification, I followed it step by step everything went great up to the point that I'm running the application on my device I don't get the alert "MyApp" would like to send you push notifications and I'm not seeing myApp in settings --> notification center
I've added like the tutorial said the following code in appdelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Let the device know we want to receive push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
but when I'm trying to find out which types of push notifications are enabled using this line of code in my first viewDidLoad
UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
I'm getting UIRemoteNotificationTypeNone
Any Ideas?
Upvotes: 0
Views: 252
Reputation: 2642
You have to make sure your app (in developer portal) is setup for Push notifications;
If you have enabled Push Notifications for your app, you will need to regenerate your Provisioning Profile so it will include the Push Certificate details. Also insure you have the Dev certificate for the Push Notifications in your keychain
If you haven't enabled Push Notifications for your app, you will need to create a Push Certificate for Development and Production. After you have created (and installed the Push Certificate in your Keychain) you will need to regenerate your Provisioning Profile so it includes the Push Certificate details.
Remove your old Provisioning file and install your new one you should get the alert to allow pushNotifications
Upvotes: 1
Reputation: 1869
These are the steps that solved my problem (although I have no clue why the problem was happening in the first place)
didRegisterForRemoteNotificationsWithDeviceToken
function was called :)Note: the viewDidLoad
with the line UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
stil returns UIRemoteNotificationTypeNone
I'm guessing in a race condition with everything being async it's being called before the notification is being set.
Upvotes: 0