Open Youthleap423 opened 3 years ago
my log is: [User Defaults] Couldn't read values in CFPrefsPlistSource
same thing for me, following the instruction on the readme this, I can not get darta on widget. It shows it saves in the app but it does not show up in the widget or userdefault storage
+1
+1
+1 extension also
Finally I managed to get it work
In widget side, we can get the data like so in the timeline `
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline
var user: User?
do {
let shared = userDefaults?.string(forKey: "user")
print("data", shared)
if(shared != nil){
user = try JSONDecoder().decode(User.self, from: shared!.data(using: .utf8)!)
}
} catch{
print(error)
}
let entry = UserEntry(date: Date(), configuration: ConfigurationIntent(), user: user)
let timeline = Timeline(entries: [entry], policy: .atEnd)
completion(timeline)
} ` then in the entry view, you can get this user data by entry.user
WidgetBridge.reloadWidget('MyApp_Widget')
every time you do some changesI'm not sure this is the best way to deal with it or not, but it works for me
I think the group identifier can be anything. Make sure to add same App Group and check the check box in both the app and the widget configuration.
Finally I managed to get it work
- The identifier for app group should have some postfix, for example, your main app identifier is com.domain.myapp, then you app group identifier should be group.com.domain.myapp.store
In widget side, we can get the data like so in the timeline `
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { let userDefaults = UserDefaults(suiteName:"group.com.domain.myapp.store) var user: User? do { let shared = userDefaults?.string(forKey: "user") print("data", shared) if(shared != nil){ user = try JSONDecoder().decode(User.self, from: shared!.data(using: .utf8)!) } } catch{ print(error) } let entry = UserEntry(date: Date(), configuration: ConfigurationIntent(), user: user) let timeline = Timeline(entries: [entry], policy: .atEnd) completion(timeline) }
` Then in the entry view, you can get this user data by entry. user
- Can also use react-native-widget-bridge, call
WidgetBridge.reloadWidget('MyApp_Widget')
every time you do some changesI'm not sure if this is the best way to deal with it or not, but it works for me
@duyhodev Hello,
I hope you're doing well.
I've integrated this library to store data in the app group and successfully used SharedGroupPreferences.setItem and SharedGroupPreferences.getItem.
However, when attempting to fetch the stored data on the iOS native side, it returns nil values.
Could you please provide guidance on whether there are any extra configurations needed?
I've created a widget extension, but I'm unsure if additional code needs to be written inside the extension file.
Thank you in advance for your assistance.
I did integrations with the help of this document: https://www.cristiangutu.pro/share-data-between-react-native-and-ios-widgets/
@duyhodev Can you please help me??????
Do you have any other account to chat with me?
On Mon, Mar 18, 2024 at 2:27 AM naveedashfaq272 @.***> wrote:
@duyhodev https://github.com/duyhodev Can you please help me??????
— Reply to this email directly, view it on GitHub https://github.com/KjellConnelly/react-native-shared-group-preferences/issues/24#issuecomment-2003018964, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIHFWCSRNGTUH7ZMVJXNFUTYY2CODAVCNFSM5C5OLMP2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBQGMYDCOBZGY2A . You are receiving this because you authored the thread.Message ID: <KjellConnelly/react-native-shared-group-preferences/issues/24/2003018964@ github.com>
Do you have any other account to chat with me? … On Mon, Mar 18, 2024 at 2:27 AM naveedashfaq272 @.***> wrote: @duyhodev https://github.com/duyhodev Can you please help me?????? — Reply to this email directly, view it on GitHub <#24 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIHFWCSRNGTUH7ZMVJXNFUTYY2CODAVCNFSM5C5OLMP2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBQGMYDCOBZGY2A . You are receiving this because you authored the thread.Message ID: <KjellConnelly/react-native-shared-group-preferences/issues/24/2003018964@ github.com>
@sekoucox7913 Yes, I do have multiple accounts. let me know which one is suitable for you??
Do you have any other account to chat with me? … On Mon, Mar 18, 2024 at 2:27 AM naveedashfaq272 @.***> wrote: @duyhodev https://github.com/duyhodev Can you please help me?????? — Reply to this email directly, view it on GitHub <#24 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIHFWCSRNGTUH7ZMVJXNFUTYY2CODAVCNFSM5C5OLMP2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBQGMYDCOBZGY2A . You are receiving this because you authored the thread.Message ID: <KjellConnelly/react-native-shared-group-preferences/issues/24/2003018964@ github.com>
"Hey @sekoucox7913 and @duyhodev, can you please help me out? I'm facing an issue and I was wondering if any of you have dealt with something similar and could offer some advice. Thanks in advance!"
@naveedashfaq272 Can you share your code snippet? shared data setting part on the react native side and getting part on the ios native side.
@naveedashfaq272 Can you share your code snippet? shared data setting part on the react native side and getting part on the ios native side.
Hey @sekoucox7913, I have attached screenshots that show the code snippets you asked for. They cover the shared data setting part on the React Native side and the getting part on the iOS Native side. If you have any further queries, feel free to let me know.
Can you check this?
Can you check this?
I checked but the issue is still same.
Can you check this?
Do I need to add additional code in the widget extension too?
No need, it seems group default is null. It means it is trying to get value before setting value.
No need, it seems group default is null. It means it is trying to get value before setting value.
thanks for your help let me try to debug the settings.
I have made widget extension with app and tried to share data between them. but It is not working. I can't get data on widget. Can you tell me about issues?