Issue
I am trying to use CapacitorSQLite with capacitor 3. When I call SQLite.requestPermission() its not showing any dialog box asking for permission and the code seems to be never returning from that call as I can see logs before that call but not after.
code look like
async init(): Promise<void> {
if (this.platform.is('android')) {
try {
const sqlite:any = CapacitorSQLite;
console.log('setting permission handler');
this.handlerPermissions = sqlite.addListener(
'androidPermissionsRequest', async (data:any) => {
if (data.permissionGranted === 1) {
console.log('Perm granted');
this.setupDatabase();
} else {
console.log("Permission not granted");
}
});
console.log('REQUESTING PERMS');
await sqlite.requestPermissions();
} catch (e) {
console.log('error on perm req',e);
const alert = await this.alertCtrl.create({
header: 'No DB access',
message: e.message,
buttons: ['OK']
});
await alert.present();
}
} else {
console.log('not running on android platform');
const alert = await this.alertCtrl.create({
header: 'Not android',
message: this.platform.platforms()[0],
buttons: ['OK']
});
await alert.present();
this.setupDatabase();
}
}
can see the following logs
'setting permission handler' 'REQUESTING PERMS'
but am also expecting one of the following as well
'Perm granted' "Permission not granted" 'error on perm req'
here's AndroidManifest.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name="io.ionic.starter.MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Am I missing anything? Capacitor doc says plug will have user-permission that need to be added but couldn't see any for sqlite.
Thanks a lot
Solution
You do not need specific permissions for this plugin. Check the documentation for examples of how to use this plugin in Angular, React or Vue depends on what you need.
Answered By - Danil Prokhorenko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.