Reference to shared class instance of main app in Notification Service Extension

Hi everyone.
I have an issue when access to a singleton class in main app when I’m in notification extension. The data in that shared class always return empty although it have values when access in main app.

@tringuyen623 Thanks very much for your question!

Is it possible for you to share some code so that others can see what it is you are trying to do?

In notification service extension I tried to access UNUserNotificationCenter.current().getDeliveredNotifications but it always return 0 although in main app it have values. And another class like this:
final class CurrentUserData {

private init () {}

static let shared = CurrentUserData()

var datas: [Data] = []


When i received notifications, I want to access datas in notification service extension but it always return 0

@tringuyen623 notification service and main app are two different process. To share data between them you need to use the app group to store data in shared user defaults and access the value from them

I already used app group.

This topic was automatically closed after 166 days. New replies are no longer allowed.