Regarding Local push Notification, how could I launch NEAppPushManager

Hi I working on local push connectivity. the enviremant setting has all been done. Something like Entitlement, permission, provision profile.....

Now I'm starting the process below from AppDelegate. it didn't come out any error, but NEAppPushManager didn't activate eventually as well.

result log,

is active: Optional(false)

My goal is to launch the NEAppPushProvider, and have no idea how to make it work.

below is provider entitlements

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.developer.networking.networkextension</key>
	<array/>
	<key>com.apple.security.app-sandbox</key>
	<true/>
	<key>com.apple.security.application-groups</key>
	<array>
		<string>group.xxx.xxxx.testpushnotification</string>
	</array>
	<key>com.apple.security.network.client</key>
	<true/>
</dict>
</plist>

I've read about this artical https://developer.apple.com/forums/thread/705382

the load and save process will got error like

2022-07-12 17:56:25.339269+0800 SocketPushNotification[2843:623554] [] <NEAppPushManager: 0x282359740>: Failed to save the configuration: Error Domain=NEConfigurationErrorDomain Code=9 "configuration is unchanged" UserInfo={NSLocalizedDescription=configuration is unchanged}
did not save configuration, error: %{public}@ The operation couldn’t be completed. (NEAppPushErrorDomain error 3.)

please give me some advices thank you.

I've removed

mgr.saveToPreferences { error in
    if let error = error {
        print("Couldn't save push manager prefs: \(error)")
    }
}

and add

localManager.loadFromPreferences { error in
    precondition(Thread.isMainThread)
    
    if let error = error {
        os_log("Error loading NEAppPushManager: %{public}@", error.localizedDescription)
        // Handle error
        return
    }
    
    localManager.saveToPreferences { error in
        if let nsError = error as NSError? {
            os_log("did not save configuration, error: %{public}@", nsError.localizedDescription)
            // Handle error
            return
        }
        os_log("Did Save Configuration Successfully")
        // Checkout logs here
    }
}

result came out as below

is active: Optional(false)
Did Save Configuration Successfully

It seems that the setting for push manager in done, but NEAppPushProvider still not working.

Accepted Answer

I've found out the reason few days ago.

we can't see the log inside NEAppPushProvider unless using cmd+shift+2 to watch all logs from phone.

And you'll find out that NEAppPushProvider is launched already.

So, maybe this can help.

Regarding Local push Notification, how could I launch NEAppPushManager
 
 
Q