I am developing the app where app can behave as both Central and Peripheral in foreground and background. That is working fine by using state preservation and restoration.
Now the next requirement is like both app (Central & Peripheral) are nearby but should connect automatically only when there is push notification fired from backend.
So as soon as push notification arrive, app should wake up, Start advertising as Peripheral and Central look for peripheral with fixed service UUID.
I tried to initialise both peripheral and central role on app wakeup by push notification but it never get connect with each other and exchange data.
So question is how can i achieve this waking up app by Push notification and then connect with other iphone's peripheral and other iphone's central to current iphone and exchange data.
Here i am trying to wake up app when notification arrives :
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
localPeripheralManager = PeripheralManager(delegate: self)
localCentralmanager = CentrallManager(delegate: self)
completionHandler(UIBackgroundFetchResult.newData)
}
Selecting any option will automatically load the page