Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Notification Crash during Boot Phase (DirectBoot) #1810

Open
mlostekk opened this issue Sep 25, 2023 · 2 comments
Open

Local Notification Crash during Boot Phase (DirectBoot) #1810

mlostekk opened this issue Sep 25, 2023 · 2 comments

Comments

@mlostekk
Copy link

Bug Report

Plugin(s)

"@capacitor/local-notifications": "^5.0.6",

Capacitor Version

💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 5.4.1
  @capacitor/core: 5.4.1
  @capacitor/android: 5.4.1
  @capacitor/ios: 5.4.1

Installed Dependencies:

  @capacitor/cli: 5.4.0
  @capacitor/core: 5.4.0
  @capacitor/android: 5.4.0
  @capacitor/ios: 5.4.0

Platform(s)

  • Android

Current Behavior

The following Crash is reported to the Google Play Console

ndroid.app.ContextImpl.getSharedPreferences
java.lang.IllegalStateException

with the stacktrace

Exception java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
  at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:562)
  at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:547)
  at android.content.ContextWrapper.getSharedPreferences (ContextWrapper.java:196)
  at com.google.android.gms.internal.appset.zzl.zzf (com.google.android.gms:play-services-appset@@16.0.0:1)
  at com.google.android.gms.internal.appset.zzl.zzd (com.google.android.gms:play-services-appset@@16.0.0:1)
  at com.google.android.gms.internal.appset.zzh.run
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
  at java.lang.Thread.run (Thread.java:1012)

Expected Behavior

No Crash

Additional Info

It seems like this is happening when the notification system signs up during boot, before the user unlocked his device. (source). Looking at the manifest of this it is exactly what is happening (here, and here)

Is it possible to disable these manifest values without forking the whole repository?

@mlostekk
Copy link
Author

Is it somehow possible to disable the "directBoot" awareness without forking the whole repository? Nobody else having an production app and is seeing this issue?

@TeaKave
Copy link

TeaKave commented Dec 12, 2023

Hi. We had a similar issue. To override this behaviour we added the following piece of code to app AndroidManifest:

<receiver
            android:name="com.capacitorjs.plugins.localnotifications.LocalNotificationRestoreReceiver"
            android:exported="false"
            tools:node="replace">

            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            </intent-filter>
</receiver>

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants