简体   繁体   中英

Push Notification without using internet,wifi,APNS and apple push notification server

I need to write an IOS app to let a few IOS devices to send local notifications to each other WITHOUT external Internet connection (without using APNS -- apple push notification server). The environment will be a private internal WIFI network with a dedicated server...

Scanario

we work in a bank office all 14 people using Iphones Person A send notification to rest of the 13 people all will recieve the notification one person in the group (for example, Person H) reply back and Person A can recieve Person H's reply not external internet all iphone what we have is a private wifi network, set up by a server . TOTALLY NO LINK to outside world..no link to outside internet

If it is possible in ios app. using swift 3.0. If It's possible can you please guide me.

You can implement this kind of functionality by using a combination Background fetch ( Apple documentation ) and local notifications , if you have a server inside the network that contains the information which is needed to show the notification. Conceptually this would work like this:

  1. Setup the app to fetch the data periodically from your server inside internal network using background fetch functionality.
  2. When the server sends you the information that should notify the user, show the local notification.

There are three things to remember in this approach, though.

  • Your app does not receive the notification if it is not running in the background, ie your users will need to remember to keep the app running in the background.
  • The background data fetch is not completely reliable, and Apple may not fire it on time ie. when the device is in the battery save mode. This may or may not be okay for your use case (you'd want to test it).
  • You need to test that your iPhones do not disconnect from the wifi when going to the sleep mode; otherwise your background fetch logic will not work.

EDIT: For example like this:

  1. In project settings, enable Capabilities -> Background Modes -> Background fetch
  2. set minimum interval in your AppDelegate.didFinishWithLaunchOptions method, for example:

UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)

  1. implement the handler method in the AppDelegate:

func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping 
(UIBackgroundFetchResult) -> Void {
    fetchData() { data in 
         if data.needsToBeNotified {
             sendLocalNotification()
         }
         completionHandler(.newData)
    }
}

RayWenderlich have a nice tutorial about the background modes: https://www.raywenderlich.com/143128/background-modes-tutorial-getting-started

The scenario can be addressed using MQTT Protocol within the Wi-Fi network. You will have to set up an MQTT Broker within the network and Make an MQTT Client in your iOs App. You can subscribe the MQTT Client to the MQTT broker on a topic same as GCM works and use MQTT Broker to send Push Notification to topics subscribed by MQTT Clients.

Example for Android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM