Issue
My app currently asks for permissions when users open activities, I would like to have those permissions on app first load.
Example
One of my components (activity) needs callNumber permission and asking for this permission won't be popup until user opens that component, I would like to have that permission popup when user install the app for first time instead of when user goes to that specific activity.
Code
MyComponent.ts
(my custom component activity
that calling happen in that page)
import { CallNumber } from '@ionic-native/call-number/ngx';
constructor(
private callNumber: CallNumber,
) {...}
callEmergencies(event: any) {
this.callNumber.callNumber(event, true)
.then(res => {
Toast.show({
text: 'Calling ' + res + ' ...'
});
})
.catch(err => {
Toast.show({
text: 'something went wrong.'
});
});
}
App.module.ts
(main module)
import { CallNumber } from '@ionic-native/call-number/ngx';
providers: [
CallNumber,
],
app.component.ts
(Main component)
Has nothing about CallNumber
plugin.
Question
How can I achieve that logic (asking permissions on first launch instead of in each activity)?
Solution
This is not possible or preferable. The new permissions paradigm is to request permissions when needed ('in context'). This way, the user should be in no doubt as to why you are requesting permission.
From the Android documentation:
Ask for permissions in context, when the user starts to interact with the feature that requires it.
iOS shares this idea:
Request personal data only when your app clearly needs it.
Answered By - Alex Steinberg
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.