Dear Apple Support Team,
I am trying to shared data between two different App target. Target A is main iOS app and Target B is Intent Extension. I have create app group and utilise app group to share data between different target but when setting the user default from Target B stile getting container null.
Target B UserDefault object details
sharedDefaults UserDefaults 0x0000600000c05110
baseNSObject@0 NSObject
kvo id 0x0 0x0000000000000000
[0] id
identifier __CFString * "group.com.xxxx. xxxx" 0x0000600001704900
container __CFString * NULL 0x0000000000000000
_volatileDomainNames id 0x0 0x0000000000000000
[0] id
Code snippet in Target B to setting UserDefault
guard let sharedDefaults = UserDefaults(suiteName: SharedUserDefaults.suitName)else {
completion(MuteIntentResponse(code: .failure, userActivity: nil))
return
}
///["event": AudioCommand.mute.rawValue]
sharedDefaults.set("test", forKey: SharedUserDefaults.Keys.audioCommand)
let didSynchronize = sharedDefaults.synchronize()
print("Intent Extension: Wrote Synchronize successful: \(didSynchronize)")
guard let command = sharedDefaults.string(forKey: SharedUserDefaults.Keys.audioCommand) else {
completion(MuteIntentResponse(code: .failure, userActivity: nil))
return
}
print("userDef \(command)")
While reading UserDefault value in Target A
UserDefault object details
baseNSObject@0 NSObject isa Class NSUserDefaults 0x01000001efe1a8a9 kvo id 0x0 0x0000000000000000 identifier __CFString * "group.com.xxxx. xxxx” 0x0000600001782200 container __CFString * NULL 0x0000000000000000 _volatileDomainNames id 0x0 0x0000000000000000 [0] id
Reading UserDefault value Code
if let def = UserDefaults(suiteName: SharedUserDefaults.suitName){
print("commandInfo (def.string(forKey: SharedUserDefaults.Keys.audioCommand))")
}
Please let me know what I am doing wrong.
Post
Replies
Boosts
Views
Activity
Hello Developers,
I'm seeking a solution to play video on CarPlay when the car is parked. Is this possible, and if so, what implementation approaches are recommended?
Dear Developers,
I'm exploring the feasibility of playing video content on CarPlay when the vehicle is in a parked state. Could you please provide guidance on whether this is supported and, if so, the best practices for implementation?