4

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.

Mounica
  • 73
  • 9
  • https://stackoverflow.com/questions/16318311/iphone-device-to-device-communication-over-wifi might help – Mohammad Sadiq Jul 22 '17 at 06:52
  • [This tutorial](http://imagineric.ericd.net/2011/04/20/ios-gamekit-iphone-to-iphone-communication/) might help..! It's kinda old one but you might get some hint for device to device communication. – Pratik Jamariya Jul 22 '17 at 07:35
  • The best solution that comes to mind is multi peer connectivity. If your all working on the same wifi, but the app will need to be running on all devices and you can Handel the incoming messages via a custom message handling class. – OverD Jul 22 '17 at 11:05

2 Answers2

2

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

satellink
  • 499
  • 2
  • 5
  • 10
  • @Monica you can see the reference for quick guide https://swifting.io/blog/2016/08/22/23-notifications-in-ios-10/ , for detail understanding check brand new userNotification framework provided by apple from iOS 10. – kaushal Jul 22 '17 at 06:50
  • @Mounica I added some sample code on how to get going, and also a link to the more detailed tutorial on background modes. – satellink Jul 22 '17 at 08:13
  • @ satellink Thank you so much.. :) – Mounica Jul 22 '17 at 08:22
0

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

iOS
  • 5,450
  • 5
  • 23
  • 25
Piyush
  • 1