Customizing the iOS permission dialog for push notifications
Asked Answered
T

7

49

When an iOS app attempts to register for push notifications for the first time, the system pops up a permissions dialog asking the user for permission to receive push notifications. Is it possible to customize the text of this dialog, to explain why these permissions are being sought?

Most permission dialog messages can be customized by putting in an NS*UsageDescription Info.plist key. For example the NSCameraUsageDescription key controls what dialog text to display when requesting access to the user's camera. But there does not appear to be such a key for push notifications.

Thimbleful answered 9/6, 2012 at 18:56 Comment(4)
I'd like to re-open this question. I remember reading somewhere that in iOS 7 you can customize the permission dialog, I can't remember where I read this now though. Can someone help?Matejka
I think the customization for permission dialogs (since iOS 6) only applies to other permission types, but for more details, you can read this question: #14159371Nadene
@DanielT. yes we can only for subtitle please see this think developer.apple.com/library/IOs/documentation/General/Reference/…Express
This is surprising, it would be relatively easy for Apple to allow the key in InfoPlist.strings. Or if there's no customization point for policy reasons, then Apple should localize it themselves like the other automatic dialogs and buttons (like "OK", "done", "cancel", etc).Nude
H
55

No, this is a system dialog which cannot be customized.

Hydrozoan answered 9/6, 2012 at 18:58 Comment(3)
As a workaround, a separate dialog can be displayed prior to taking action that would show the system permissions dialog.Thimbleful
@David Foster is it possible to change the permission dilog box (camera persmission) text to chineese ? how to do it have any idea?Scarf
@Ramesh 1. Yes, you can add whatever text you want as permission text in plist file, but for location service you can't, its system dialogue. 2. If app supports internalisation, follow this #25737200Windowlight
T
12

One workaround that I have seen involves an app bringing up its own custom dialog explaining why it needs a permission. Then immediately afterwards the app requests the permission, bringing up the system dialog.

This may be suitable for convincing a user to accept the permission request in order to gain access to a feature, or to reject the request with the knowledge that the feature will not be available.

Thimbleful answered 21/11, 2013 at 2:30 Comment(1)
Yep, like in this example: techcrunch.com/2014/04/04/…Back
G
7

I don't know if you mean the text under title like this image

enter image description here

If yes, modify your info.plist file. Adding a new key Privacy - User Notifications Usage Description, this is also a Xcode inbuilt option, you can select from menu. Then type what ever text in value.

enter image description here

Here's request code in AppDelegate didFinishLaunchingWithOptions:

if UserDefaults.shared.isFirstLaunch {
    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in
        if success {
            print("All set!")
        } else if let error = error {
            print(error.localizedDescription)
        }
    }
    UserDefaults.shared.isFirstLaunch = false
}

Gunstock answered 14/4, 2022 at 15:47 Comment(7)
Doesn't work for me.Alleyn
@Alleyn Hi, which iOS version are you using?Gunstock
iOS 15.5 @RogerAlleyn
@Alleyn I've added my code sample in answer and set custom description to 'Hello pors', it seems working fine on iOS 15.5, could you show me more about your code? Screenshot: imgur.com/X9VAwlMGunstock
I work with Expo (React Native), but I'm able to add entries to info.plistAlleyn
@Alleyn Sorry, this answer is for native iOS appGunstock
Maybe add the Info.plist key so people trying to add this outside of Xcode can easily follow. It is NSUserNotificationsUsageDescription.Freese
H
5

Not possible, since you dont have any control on it whatsoever

Howze answered 9/6, 2012 at 19:1 Comment(0)
O
4

No you cant change system in built message.because you dont have any control to it.

Overstuffed answered 29/8, 2012 at 9:2 Comment(0)
F
1

As Septronic pointed out, at least as of macOS 12.3 / iOS 15.4, the body of the prompt to allow notifications can be customized using the not-really-documented NSUserNotificationsUsageDescription Info.plist key.

You can add a value for the key Privacy - User Notifications Usage Description to your app's Info.plist with the desired string. If you edit the XML Plist directly, use this

<key>NSUserNotificationsUsageDescription</key>
<string>Your description goes here.</string>
Fortification answered 17/2, 2023 at 11:37 Comment(0)
I
-1

System dialog title cannot be customized. But you can customize description message underneath.

Incestuous answered 9/6, 2022 at 14:56 Comment(2)
> But you can customize description -- How?Thimbleful
@DavidFoster I can't edit my post, but you can either add a value for this key Privacy - User Notifications Usage Description (if you open as property list), or this (if as source code): ``` <key>NSUserNotificationsUsageDescription</key> <string></string> ```Tzar

© 2022 - 2024 — McMap. All rights reserved.