Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Check for push notification support in the app

I added Push notifications to my application. And my application works based on push notifications. When the app runs for the first time, it is showing alert whether user wants to receive push notifications or not. Is it possible to make it mandatory to accept push notifications? Or if this is not possible, can we check whether push notifications are set for this app or not and terminate the application with alert?

like image 373
Satyam Avatar asked Oct 26 '11 04:10

Satyam


People also ask

How do you check push notifications on iPhone?

Find your notifications in Notification CenterOn the Lock Screen: Swipe up from the middle of the screen. On other screens: Swipe down from the top center. Then you can scroll up to see older notifications, if there are any.

Does iOS support push notification?

An iOS push notification is a message that pops up on an Apple device such as an iPhone. Before receiving push notifications from an app, iOS device users must explicitly give permission. Once a user opts-in, mobile app publishers can send push notifications to the users' mobile devices.

How do I set up push notifications on iOS app?

Setting up Push Notifications in iOS. Go back to the iOS project you created earlier and select the main target. Under the Signing & Capabilities tab, click on the + Capability button, then select Push Notifications. This will enable your app to receive push notifications from OneSignal.


2 Answers

You can only check whether user have selected to receive push-notifications:

UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (status == UIRemoteNotificationTypeNone)
{
    NSLog(@"User doesn't want to receive push-notifications");
}
like image 156
Nekto Avatar answered Nov 02 '22 23:11

Nekto


//It's better to use the followiing instead

BOOL status = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications]; if (!status) { NSLog(@"User doesn't want to receive push-notifications"); }

like image 21
Elsammak Avatar answered Nov 02 '22 23:11

Elsammak