NEAppPushProvider Stop not being called after disconnecting from specified SSID

Hello,

I have been implementing NEAppPushProvider class to establish my own protocol to directly communicate with our provider server without the need to rely on APNs for background push notifications.

I am at a stage where I am able to establish a tcp communicator and receive messages back and forth but I noticed that when I disconnect from the WIFI I've set up by setting a given SSID, I am not getting hit on the Stop method. Below is briefly how I load and save preferences.

NEAppPushManager appPushManager = new NEAppPushManager();
				appPushManager.LoadFromPreferences((error) =>
				{
					if (error != null)
					{
						Console.WriteLine($"Error loading NEAppPushManager preferences: {error.LocalizedDescription}");
						return;
					}

					if (!enable)
					{
						Console.WriteLine("Disabling Local Push Provider...");
						appPushManager.Enabled = false;
						
						// ✅ Immediately update UserDefaults before saving preferences
						userDefaults.SetBool(false, Constants.IsLocalPushEnabled);
						userDefaults.Synchronize();

						appPushManager.SaveToPreferences((saveError) =>
						{
							if (saveError != null)
							{
								Console.WriteLine($"Error disabling Local Push: {saveError.LocalizedDescription}");
							}
							else
							{
								Console.WriteLine("Local Push successfully disabled.");
							}
						});
						return;
					}

					// ✅ Now we can safely enable Local Push
					Console.WriteLine($"Enabling Local Push for SSID: {_currentSSID}");
					appPushManager.MatchSsids = new string[] { _currentSSID };
					appPushManager.LocalizedDescription = "LocalPushProvider";
					appPushManager.ProviderBundleIdentifier = Constants.LocalPushExtensionBundleId;
					appPushManager.Enabled = true;

					appPushManager.SaveToPreferences((saveError) =>
					{
						if (saveError != null)
						{
							Console.WriteLine($"Error saving Local Push settings: {saveError.LocalizedDescription}");
						}
						else
						{
							Console.WriteLine("✅ Local Push successfully registered.");
							userDefaults.SetBool(true, Constants.IsLocalPushEnabled);
							userDefaults.Synchronize();
						}
					});
				});

I've read through documentation and was expecting the Stop method to be hit when I turn off Wifi. Am I missing anything? Please let me know if I should provide more info. Currently I just have a console writeline method inside the Stop method to see if it actually gets hit.

I've read through documentation and was expecting the Stop method to be hit when I turn off Wifi.

Keep in mind that the sample project "Receiving Voice and Text Communications on a Local Network" has a full implementation of this extension point. You may want to get the working before you start your own implementation.

Am I missing anything? Please let me know if I should provide more info. Currently I just have a console writeline method inside the Stop method to see if it actually gets hit.

Are you testing with the Xcode debugger? Xcode distorts a lot process lifetime behavior* and it may be breaking the "stop" logic here. If you're testing with the debugger, try testing without it before you assume that anything is actually going wrong.

I'd also suggest taking a look at Quinn's "Debugging a Network Extension Provider". It's not directly about Push Provider, but most of it's advice is directly applicable for similar reasons.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

NEAppPushProvider Stop not being called after disconnecting from specified SSID
 
 
Q