Closed
Description
I'm running into issues with requestPermission on Android 13.
in app.gradle
targetSdkVersion 33
in manifest
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
in package.json
deps
"@nativescript/angular": "~14.2.0",
"@nativescript/core": "~8.3.5",
"@nativescript/firebase-core": "^2.4.4",
"@nativescript/firebase-crashlytics": "^2.4.4",
"@nativescript/firebase-messaging": "^2.4.4",
dev-deps
"@nativescript/android": "8.3.1",
"@nativescript/ios": "8.3.3",
"@nativescript/types": "~8.3.1",
I have this code:
main.ts
import {firebase} from '@nativescript/firebase-core';
import '@nativescript/firebase-messaging';
import '@nativescript/firebase-crashlytics';
some.service.ts
constructor()
firebase().initializeApp()
.then(firebaseApp => {
const messaging = firebase().messaging();
messaging.onMessage(this.onMessage);
messaging.onNotificationTap(this.onNotificationTap);
})
.catch(error => this.loggerService.error('Firebase::Failed to initialize', error));
In another method:
registerToken()
const messaging = firebase().messaging();
messaging.requestPermission({ios: iosPermissions}).then(authStatus => {
const granted = authStatus === AuthorizationStatus.AUTHORIZED || authStatus === AuthorizationStatus.PROVISIONAL;
if (granted) {
messaging.registerDeviceForRemoteMessages()
.then(result => {
messaging.getToken().then(token => this.storeToken(token));
messaging.onToken(this.onTokenCallback);
})
.catch(error => this.loggerService.error('register failed', error));
}
}).catch(error => this.loggerService.error('request permission failed', error));
Then I have "some.component.ts" using the "some.service.ts", and I get this error
request permission failed Error: Cannot assign primitive value to array of objects.
at requestPermission (file: src/webpack:/my-app/node_modules/@nativescript/firebase-messaging-core/index.android.js:258:0)
...
It points to this code (index.android.js:258:0):
const perms = Array.create('java.lang.String', 1);
perms[0] = android.Manifest.permission.POST_NOTIFICATIONS; // line 258
activity.requestPermissions(perms, 1001);
This is working fine in earlier Android versions. (also without the app.gradle and manifest changes).
Any tips on how to solve this?
I checked two other cases #125 and #144, but they seemed to have other issues.
Metadata
Metadata
Assignees
Labels
No labels