Home What? iOS 12 Can Receive Push Notifications Without User Authorization (Swift)
Post
Cancel

What? iOS 12 Can Receive Push Notifications Without User Authorization (Swift)

What? iOS 12 Can Send Push Notifications Without User Authorization (Swift) — (Updated 2019-02-06)

Introduction to UserNotifications Provisional Authorization and iOS 12 Silent Notifications

MurMur……

Recently, I was improving the low permission and click-through rates of APP push notifications and made some optimizations. The initial version had a very poor experience; as soon as the APP was installed and launched, it directly popped up a window asking “APP wants to send notifications.” Naturally, the rejection rate was very high. According to the statistics from the previous article using Notification Service Extension, it is estimated that only about 10% of users allowed push notifications.

Currently, the new installation guide process has been adjusted, and the timing of the notification permission window has been optimized as follows:

[Wedding APP](https://itunes.apple.com/tw/app/%E7%B5%90%E5%A9%9A%E5%90%A7-%E4%B8%8D%E6%89%BE%E6%9C%80%E8%B2%B4-%E5%8F%AA%E6%89%BE%E6%9C%80%E5%B0%8D/id1356057329?ls=1&mt=8){:target="_blank"}

Wedding APP

If the user is still hesitant or wants to try the APP before deciding whether to receive notifications, they can click “Skip” in the upper right corner to avoid the irreversible result of pressing “Don’t Allow” due to unfamiliarity with the APP at the beginning.

Getting to the Point

While working on the above optimization, I discovered that UserNotifications in iOS 12 added a new .provisional permission. In plain language, it is a temporary notification permission that allows sending push notifications (silent notifications) to users without popping up a notification permission window. Let’s see the actual effect and limitations.

How to Request Provisional Notification Permission?

1
2
3
4
5
6
7
8
9
10
if #available(iOS 12.0, *) {
    let center = UNUserNotificationCenter.current()
    let permissions: UNAuthorizationOptions = [.badge, .alert, .sound, .provisional]
    // You can request only provisional permission .provisional, or request all necessary permissions at once XD
    // It will not trigger the notification permission window
    
    center.requestAuthorization(options: permissions) { (granted, error) in
        print(granted)
    }
}

We add the above code to AppDelegate didFinishLaunchingWithOptions and then open the APP. We will find that the notification permission window does not pop up. At this time, we go to Settings to check APP Notification Settings.

(Figure 1) Obtaining Silent Notification Permission

(Figure 1) Obtaining Silent Notification Permission

We have quietly obtained the silent notification permission 🏆

In the code, add the authorizationStatus .provisional item (only for iOS 12 and later) to determine the current push notification permission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if #available(iOS 10.0, *) {
    UNUserNotificationCenter.current().getNotificationSettings { (settings) in
        if settings.authorizationStatus == .authorized {
            // Allowed
        } else if settings.authorizationStatus == .denied {
            // Not allowed
        } else if settings.authorizationStatus == .notDetermined {
            // Not asked yet
        } else if #available(iOS 12.0, *) {
            if settings.authorizationStatus == .provisional {
                // Currently provisional permission
            }
        }
    }
}

Note! If you are checking the current notification permission status, settings.authorizationStatus == .notDetermined and settings.authorizationStatus == .provisional can both trigger a notification prompt asking the user whether to allow notifications.

What can silent notifications do? How are they displayed?

Let’s start with a diagram summarizing when silent notifications will be displayed:

As you can see, if it is a silent push notification, when the app is in the background state, the notification will not show a banner, will not have a sound alert, cannot be marked, and will not appear on the lock screen. It will only appear in the notification center when the phone is unlocked:

You can see the push notifications you sent, and they will automatically aggregate into a category.

After clicking to expand, the user can choose:

This expanded prompt window will only appear under silent push with "provisional permission"

This expanded prompt window will only appear under silent push with “provisional permission.”

  1. To “continue” receiving push notifications — “Send important notifications”: All notification permissions will be fully granted! All notification permissions will be fully granted! All notification permissions will be fully granted! It’s really important, so I said it three times. At this point, the code requesting permissions earlier will have a significant effect. Or maintain receiving silent notifications.
  2. “Turn off” — “Turn off all notifications” will completely disable push notifications (including silent notifications).

Note: How to manually set the existing app to silent notifications?

Silent notifications are a new setting introduced with iOS 12 for notification optimization and are unrelated to provisional permissions. It’s just that the program can send silent notifications when it gets provisional permissions. Setting an app’s notifications to silent is also very simple. One method is to go to “Settings” - “Notifications” - find the app and turn off all permissions except “Notification Center” (as shown in the first image), which is silent notifications. Or, when receiving an app notification, press/long press to expand, then click the top right “…” and choose to send silent notifications:

When triggering the notification prompt window with provisional permissions:

Remove the .provisional part when requesting notification permissions to still normally ask the user whether to allow notifications:

1
2
3
4
5
6
7
if #available(iOS 10.0, *) {
    let center = UNUserNotificationCenter.current()
    let permissions: UNAuthorizationOptions = [.badge, .alert, .sound]
    center.requestAuthorization(options: permissions) { (granted, error) in
        print(granted)
    }
}

Press “Allow” to get all notification permissions, press “Don’t Allow” to turn off all notification permissions (including the previously obtained silent notification permissions).

The overall process is as follows:

Summary:

This thoughtful notification optimization in iOS 12 makes it easier to build an interactive bridge between users and developers regarding notification functionality, minimizing the chances of notifications being permanently turned off.

For users, when the notification prompt window pops up, they often don’t know whether to press allow or deny because they don’t know what kind of notifications the developer will send. It could be ads or important messages. The unknown is scary, so most people will conservatively press deny.

For developers, we have carefully prepared many items, including important messages to push to users, but due to the above issue, users block them, and our thoughtfully designed copy goes to waste!

This feature allows developers to seize the opportunity when users first install the app, design the push process and content well, prioritize pushing items of interest to users, increase users’ awareness of the app’s notifications, and track push click rates, then trigger the prompt asking users whether to allow notifications at the right time.

Although the only exposure is in the Notification Center, having exposure means having a chance. From another perspective, if we were users and didn’t allow notifications, and the app could still send a bunch of notifications with banners, sounds, and appearing on the unlock screen, it would be very annoying (like the other camp XD). Apple’s approach strikes a balance between users and developers.

The current issue is probably… there are still too few iOS 12 users 🤐

2019-02-06 Update on practical application:

In practice, I have “canceled” the implementation of this feature.

Why?

Because it was found that users would passively enter silent push notification mode in the following situations, they need to manually turn on all push notification permissions (banners, sounds, badges).

It’s a bit awkward, which means that if the user denies notification permissions when asked and then turns them on in settings, only silent notification permissions will be enabled. Asking the user to turn on banners, sounds, and badges below is a bit difficult, so for now, it has been temporarily disabled.

Further Reading

If you have any questions or comments, feel free to contact me.

===

本文中文版本

===

This article was first published in Traditional Chinese on Medium ➡️ View Here



This post is licensed under CC BY 4.0 by the author.

All About iOS UUID (Swift/iOS ≥ 6)

Handling Push Notification Permission Status from iOS 9 to iOS 12 (Swift)