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.