I have a UWP app with a WebView that may browse to webpages that request special permissions like the microphone, camera, or geolocation. For instance, I login to web.skype.com, it will request microphone and camera access. I added these capabilities to the appxmanifest so that it Windows prompts for permission. The problem with this is that I have no control over the UI of the popup that is displayed. My users may have special access needs (e.g. using an eye tracker) and I want to ensure they do not get stuck if one of these dialogs appears.
1) Is there any event or notification that Windows is about to show the dialog? I thought WebView.PermissionRequested was supposed to do this, but I am seeing that it is not invoked when I go to web.skype.com for microphone/camera permission, nor for weather.com for geolocation permission. Is there a different event at the app level that I can use for this? That way I can at least warn the user that a non-accessible dialog is about to appear so that they can prepare for it (e.g. ask for help).
Edit: For instance, app.xaml.cs has some virtual methods like OnFileOpenPickerActivated. I need something like OnPermissionRequested.
2) Is it possible to customize this UI in any way? Preferably I could replace the whole thing with my view. Next best would be to change the text to something like "Let web.skype.com access your microphone?" rather than "Let access your microphone?"
My question was answered in the msdn forums, quoted here:
Hi J.Nelson Tdx
Is there any event or notification that Windows is about to show the dialog?
The dialog will appear only when you need to use the related APIs. There is no such event that could will be fired before the permission dialog shows. You could submit a feature request in the User Voice.
Is it possible to customize this UI in any way?
Currently, it is not possible to customize the Warning Alert. This is by design.
Best regards,
Roy
Related
I am currently developing an Outlook Add-In that receives a notification whenever a change in the user's calendar is recorded. The thing is that, there are some occasions where we would change an event's date from the backend by calling PATCH /events/eventId.
It would be very nice if there was any way to notify the user immediately, other than sending an email. Something like a popup modal with a warning message would work very well.
Currently the feature you requested is not a part of the product. We track Outlook add-in feature requests on our user-voice page. Please add your request there. Feature requests on user-voice are considered, when we go through our planning process.
I would like to customize the following part of the notification permission prompt:
Notifications may include alerts, sounds, and icon badges. These can be configured in Settings.
Is it possible to change this to my own text?
You are not able to customize this message. Read Here for more information.
The recommended way that most apps handle this is by first presenting their own dialog, then show the Apple system dialog.
So when it comes time to ask the user for notification permissions, first you trigger your own custom alert that says something like "Please allow your-app-name to send you notifications..." and maybe a brief description of why the user should allow this. With this alert, only add one action to the UIAlertController, I usually just have the action title set to "Ok" and use .default as the style. In the completion handler of this "Ok" UIAlertAction that is when you will trigger the Apple system dialogue which presents the generic UIAlertController with the option for the user to either accept or deny permissions for your app to send notifications.
So the flow is something like -> users reaches point in app where they have to decide if they want to accept or deny notifications permissions -> app presents UIAlertController that is essentially just an explanation of why the app wants/needs to send notifications -> once user taps "Ok" then trigger the generic system alert that actually makes the user choose to accept or deny notification permission.
There seems to be some psychological advantage to doing it this way. By sort of forcing the user to tap "ok" to notifications in the first dialogue, it primes them to tap "allow notifications" in the generic Apple dialogue displayed immediately after.
EDIT Dec 2020 -
Alternatively what I see a lot of apps doing now is offering an "Accept" action and a "Maybe later" action in their custom alert. If the user taps accept, then the app displays the Apple system alert which allows the user to actually Accept/Deny notifications. If the user taps "Maybe later" then the app does NOT display Apple's system dialogue. This way the user never taps DENY on the Apple system dialogue and therefore the app is still allowed to show it in the future without having to make the user manually change the app's notification preferences via the iOS settings app.
EDIT Mar 2021 - (see #blackjacx comment) Apple has rejected (at least 1) app(s) for using a "priming" dialogue before showing the system alert. So that approach seems like it is no longer allowed.
For anyone who is looking for an updated answer: This is now possible using Xcode 13 (not sure exactly what version introduced it but I was able to see it on Xcode 13.4.1 and not Xcode 13.1) by setting your custom text as the NSUserNotificationsUsageDescription key in info plist file. Unfortunately at the time of writing this, it looks like Apple released this feature with no documentation on it but I can confirm it works on devices with iOS 15.4 and above!
In XCode, you can now click your App name on the left to open it's settings, click on Info, then add a new key called "Privacy - User Notifications Usage Description" -> Then you can set the value to whatever you want that message to say.
No, this is system message, you can't change to custom.
No, I'm fairly certain that that part of the message is out of your control.
I do not believe you can change the iOS prompt, but should maybe make your own. See the guidelines that Apple has provided:
https://developer.apple.com/ios/human-interface-guidelines/interaction/requesting-permission/
Not the best resource because it does state that you can change the subtext (this is specifically for location, photos, etc.) but this, and others, have some good practices:
https://blog.clevertap.com/asking-for-ios-push-notification-permissions/
Basically, you should make your own prompt. Be sure to handle the cases where they have either said no, or turned it off in settings and redirect the user to settings, if so.
Displaying Custom Messaging Before the Alert Ideally, people already know why you’re requesting their permission based on context,
but if it’s essential to provide additional details, you can display a
custom message before the alert appears.
Make it clear that opening the system alert is the only action people
can take in your custom-messaging screen. People can interpret a
pre-alert message as a delaying tactic, so it’s critical to let them
quickly dismiss the message and view the system alert. If you display
a custom screen that precedes a privacy-related permission request, it
must offer only one action, which must display the system alert. Use a
word like "Continue" to title the action; don’t use "Allow" or other
terms that might make people think they’re granting their permission
or performing other actions within your custom screen.
Guidelines here :
https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/accessing-user-data/
Just to add clarity to Uche Nkadi 's answer, add a "Privacy - User Notifications Usage Description" key in your app's Custom iOS Target Properties. This will change the message on the notification permission alert.
I am creating an app, which needs to do something when the user presses the power button 5 times.
I figured out that it's difficult to implement in iOS, but I think it's not impossible. How do I listen for power key events, even when the app is running in the background?
Can anyone help me to find solution?
you can tap a power key once and also you cannot detect the event from your application, this is not possible in iOS as far now, better try a different way to send alert with in your app, set some conditions with in your app and then send a alert based on those conditions if satisfied, I think this would be better,
Somehow ,If you try to override the existing functionality of the power key, apple will reject your app I think so,
You can't directly get the power button events. But there are notifications which you can count like UIApplicationProtectedDataWillBecomeUnavailable or UIApplicationWillResignActiveNotification. Or just register for all low level notifications with CFNotificationCenter and see if you find something fitting like com.apple.springboard.lockstate.
I don't think you can override system level actions like holding the power button, pressing the home button, overriding the mute sound switch within your own app. iOS system doesn't exactly behave like an normal computer OS, it's to much more limited.
Apple is not allowing you to use hardware components completely. They have added some restrictions. They provided the method in the app delegate i.e. applicationDidEnterBackground can catch the home button press .Also they has provided the the API's to access the camera,bluetooth etc .At least this much of API's I know which provided by apple publicly to access the hardware. You cannot access the other hardware elements in your application which not provided publicly by apple .If you are able to do this by any way then also your application will not approved by apple .
I am working on an application in which we have a requirement to block calendar event alert or any other application alert when our application is opened. User should not see any popup from outside application when user is on any screen in our application. Please let us know if this can be done.
No, You can't do that.
From a usability perspective, it would also be problematic. Your user might actually be interested in events from other apps, while using yours.
I noticed that when my app displays the Location Services authorization dialog, the app gets suspended for a short while (it receives the UIApplicationWillResignActiveNotification notification). Is this documented or discussed somewhere? What could be the reason? Do other authorization dialogs also do it?
I’m still interested in some authoritative resources on this, but after some thinking the behaviour makes sense. The authorization dialog can’t be a part of the app, since that could create a security risk: the app could try to confirm the dialog on user’s behalf. And since the dialog is not a part of the app, it makes sense to consider the app deactivated while the pop-up is being displayed. It looks like all authorization dialogs do it.