-
Notifications
You must be signed in to change notification settings - Fork 598
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
Native Access on Preferences (iOS) #2215
Comments
This issue needs more information before it can be addressed. Please see the Contributing Guide for how to create a Sample App. Thanks! |
@Excel1 can you provide a GitHub repo with an app where the issue can be replicated? |
The reason wyh this doesnt work is, that on iOS SharedPreferences are protected from access in outer Services like NotificationServiceExtension. So you can access SharedPreferences from the app set by the plugin not from the NotificationServiceExtension. You manually have to write a sync code - so on startup you save all preferences from your app in prefernces where both (Service Extensions and the App) can access. For this you have to create an App group. AppDelegate.swift
So this issue can be closed. Maybe a hint in the documentation would be good. |
Bug Report
Im using the Preferences Plugin to store the current used locale on the device.
Now I want to access the locale in the Notification Service Extension (iOS) to modify my Notification based on the language. On Android I access the Preferences by using shared Preferences with the Prefix CapacitorStorage and everything works fine. On iOS I tried but I can't retrieve the key/value:
Plugin(s)
@capacitor/preferences V 6.0.1
Capacitor Version
Im using Quasar so
quasar info
:Platform(s)
iOS only
Current Behavior
I don't receive any key/value pair buy trying to access via native code.
Expected Behavior
Get Key/Value by using native Code
UserDefaults.standard.string(forKey: "locale")
orUserDefaults.standard.string(forKey: "CapacitorStorage.locale")
like it is on android
Other Technical Details
Testet with Xcode Version 15.1 on iPhone 16 Pro
The text was updated successfully, but these errors were encountered: