StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It supports apps which hide the status bar and The Notch

Overview

StatusBarOverlay

StatusBarOverlay Language: Swift 4.0

alt demo

StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It supports apps which hide the status bar and The Notch

Features

  • Just a few lines of code and StatusBarOverlay will automatically show & hide when internet connection is lost & regained
  • Support for apps that hide the status bar permanently
  • Support for the iPhone X Notch
  • Optionally you can choose to show the status bar anytime with custom text, eg for Debug or Demo modes
  • Optionally you can show a drop down message, below the status bar, with a click handle, great for nonintrusive alerts
  • Fully customisable colors & text

How to install

Add this to your CocoaPods Podfile

pod 'StatusBarOverlay'

How to use

In your Info.plist file set UIViewControllerBasedStatusBarAppearance = true

In your AppDelegate.didFinishLaunchingWithOptions() method set StatusBarOverlay.host to your server domain. StatusBarOverlay will use this to check connectivity

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

  StatusBarOverlay.host = "example.com"
        
  return true
}

If you use a common UIViewController subclass, add the following to it. All of view controllers show override these methods, so its best to use a common UIViewController subclass

import StatusBarOverlay // if StatusBarOverlay is in CocoaPod

extension CommonViewController {

  override var preferredStatusBarStyle: UIStatusBarStyle {
    return StatusBarOverlay.preferredStatusBarStyle
  }

  override var prefersStatusBarHidden: Bool {
    return StatusBarOverlay.prefersStatusBarHidden
  }

  override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
    return StatusBarOverlay.preferredStatusBarUpdateAnimation
  }
}

Thats it. Run your app, try turning on and off airplane mode and the No Internet Connection bar will show and hide. On the simulator sometimes the hiding event isnt fired. All devices work normally

Dependencies

  • Reachability is required for the connectivity events

Get these while stocks last :)

A Codable extension to decode arrays and to catch & log all decoding failures https://github.com/IdleHandsApps/SafeDecoder

An elegant solution for keeping views visible when the keyboard is being shown https://github.com/IdleHandsApps/IHKeyboardAvoiding

Button styles that are centralied and reusable, and hooked up to InterfaceBuilder https://github.com/IdleHandsApps/DesignableButton

Author

It'd be great to hear about any cool apps that are using StatusBarOverlay

License

Distributed under the MIT License

You might also like...
ServiceData is an HTTP networking library written in Swift which can download different types of data.

ServiceData Package Description : ServiceData is an HTTP networking library written in Swift which can download different types of data. Features List

An Alamofire extension which converts JSON response data into swift objects using EVReflection

AlamofireJsonToObjects 🚨 This is now a subspec of EVReflection and the code is maintained there. 🚨 You can install it as a subspec like this: use_fr

Codegeneration tool for isomorphic server and mobile Go apps with gRPC & Protobuf.
Codegeneration tool for isomorphic server and mobile Go apps with gRPC & Protobuf.

Codegeneration tool for isomorphic server and mobile Go apps with gRPC & Protobuf. Share code between your backend, Android & iOS app!

A type-safe, high-level networking solution for Swift apps
A type-safe, high-level networking solution for Swift apps

What Type-safe network calls made easy Netswift offers an easy way to perform network calls in a structured and type-safe way. Why Networking in Swift

An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps

PeerKit An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps Usage // Automatically detect and attach to

A Swift Package that allows iOS apps to communicate with AltServer.

AltKit allows apps to communicate with AltServers on the same WiFi network and enable features such as JIT compilation.

Control apps' wireless connectivity policy
Control apps' wireless connectivity policy

AirKeeper This tweak replicates a feature in Chinese iPhone model by using Apple's own private APIs, which effectively writes to /var/preferences/com.

Quickstart-ios-swift-grpc - Quickstart for integrating Approov with iOS apps in Swift that make API requests you wish to protect using GRPC Real-time Apps the SwiftUI way
Real-time Apps the SwiftUI way

Sync Sync is a proof of concept for expanding on the Magic of ObservableObject, and making it work over the network. This let's you create real-time A

Comments
  • Not detecting offline when airplane mode on before launching

    Not detecting offline when airplane mode on before launching

    Steps to reproduce

    1. Make sure the app process is stopped (force close if needed).
    2. Turn airplane mode on.
    3. Launch the app.
    4. Expect to see status "No internet connection", but nothing happens.
    5. Turn airplane mode off, then back on (while app's still running).
    6. Now status is visible.
    opened by avi-midtown 2
  • Layout constraints are broken in landscape mode.

    Layout constraints are broken in landscape mode.

    In landscape mode, you'll get warnings of the layout constraints. When I just remove StatusBarOverlay from my sample project, I didn't get the warnings. The status bar is hidden.

    iOS: 12.0.1 device: iPhone XS max

    `2018-10-24 10:54:48.322549+0900 testapp[5938:1838560] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x283dc85a0 UIButton:0x10be02960.width == 44 (active)>", "<NSLayoutConstraint:0x283dc97c0 H:|-(0)-[UIButton:0x10be02960] (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc9900 H:[UIButton:0x10be03150]-(0)-| (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc9950 H:[UIButton:0x10be02960]-(0)-[UIButton:0x10be03150] (active)>", "<NSLayoutConstraint:0x283dc9d60 H:[UIView:0x10be067d0]-(0)-| (active, names: '|':UIView:0x10be065f0 )>", "<NSLayoutConstraint:0x283dc9db0 H:|-(0)-[UIView:0x10be067d0] (active, names: '|':UIView:0x10be065f0 )>", "<NSLayoutConstraint:0x283de4410 'UIView-Encapsulated-Layout-Width' UIView:0x10be065f0.width == 0 (active)>" )

    Will attempt to recover by breaking constraint <NSLayoutConstraint:0x283dc85a0 UIButton:0x10be02960.width == 44 (active)>

    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. 2018-10-24 10:54:48.323375+0900 testapp[5938:1838560] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x283dc8550 UIButton:0x10be02960.width == UIButton:0x10be02960.height (active)>", "<NSLayoutConstraint:0x283dc96d0 UIView:0x10be067d0.height == 44 (active)>", "<NSLayoutConstraint:0x283dc9720 V:[UIButton:0x10be02960]-(0)-| (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc9770 V:|-(0)-[UIButton:0x10be02960] (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc97c0 H:|-(0)-[UIButton:0x10be02960] (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc9900 H:[UIButton:0x10be03150]-(0)-| (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc9950 H:[UIButton:0x10be02960]-(0)-[UIButton:0x10be03150] (active)>", "<NSLayoutConstraint:0x283dc9d60 H:[UIView:0x10be067d0]-(0)-| (active, names: '|':UIView:0x10be065f0 )>", "<NSLayoutConstraint:0x283dc9db0 H:|-(0)-[UIView:0x10be067d0] (active, names: '|':UIView:0x10be065f0 )>", "<NSLayoutConstraint:0x283de4410 'UIView-Encapsulated-Layout-Width' UIView:0x10be065f0.width == 0 (active)>" )

    Will attempt to recover by breaking constraint <NSLayoutConstraint:0x283dc8550 UIButton:0x10be02960.width == UIButton:0x10be02960.height (active)>

    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. 2018-10-24 10:54:48.326489+0900 testapp[5938:1838560] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x283dc9810 H:|-(44)-[UILabel:0x10be03660'Additional Message'] (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc9860 H:[UILabel:0x10be03660'Additional Message']-(44)-| (active, names: '|':UIView:0x10be067d0 )>", "<NSLayoutConstraint:0x283dc9d60 H:[UIView:0x10be067d0]-(0)-| (active, names: '|':UIView:0x10be065f0 )>", "<NSLayoutConstraint:0x283dc9db0 H:|-(0)-[UIView:0x10be067d0] (active, names: '|':UIView:0x10be065f0 )>", "<NSLayoutConstraint:0x283de4410 'UIView-Encapsulated-Layout-Width' UIView:0x10be065f0.width == 0 (active)>" )

    Will attempt to recover by breaking constraint <NSLayoutConstraint:0x283dc9860 H:[UILabel:0x10be03660'Additional Message']-(44)-| (active, names: '|':UIView:0x10be067d0 )>

    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. (lldb) `

    opened by mota-raven 1
  • Cocoapods not updated, latest version 2.2

    Cocoapods not updated, latest version 2.2

    The latest version on Cocoapods is 2.2, as can be seen here. But the latest version currently in the repo is 3.1.

    Could the latest version be pushed to Cocoapods please?

    opened by Zandor300 0
  • Wrong isReachable value

    Wrong isReachable value

    StatusBarOverlay.isReachable returns true when it is not reachable (view is showing correctly).

    (lldb) po StatusBarOverlay.isReachable
    true
    
    (lldb) po self.shared.reachability?.connection
    ▿ Optional<Connection>
      - some : No Connection
    
    opened by andrey-lisovskiy 0
Releases(3.1.0)
Owner
Idle Hands Apps
c/- Fraser Scott-Morrison
Idle Hands Apps
Indicates VPN state in status bar

VPNIndicator Indicates VPN state in status bar. Turn WiFi or cell signal icon to blue when VPN is active, intended for X-series iphones. Compatibility

udevs 5 Aug 24, 2022
Bonjour networking for discovery and connection between iOS, macOS and tvOS devices.

Merhaba Bonjour networking for discovery and connection between iOS, macOS and tvOS devices. Features Creating Service Start & Stop Service Stop Brows

Abdullah Selek 67 Dec 5, 2022
NWReachability - a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

NWReachability is a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

null 4 Dec 2, 2022
❌📱 A little swift Internet error status indicator using ReachabilitySwift

EFInternetIndicator Requirements Xcode 8.0+ iOS 8.3+ WARNING : It's not work on simulator. #1 Installation CocoaPods You can use CocoaPods to install

Ezequiel França 131 Dec 14, 2022
Automatically sets the network activity indicator for any performed request.

BigBrother BIG BROTHER IS WATCHING YOU. BigBrother is a Swift library made for iOS that automatically watches for any performed request and sets the n

Marcelo Fabri 446 Dec 17, 2022
SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)

SwiftSoup is a pure Swift library, cross-platform (macOS, iOS, tvOS, watchOS and Linux!), for working with real-world HTML. It provides a very conveni

Nabil Chatbi 3.7k Dec 28, 2022
Swift backend / server framework (Pure Swift, Supports Linux)

NetworkObjects NetworkObjects is a #PureSwift backend. This framework compiles for OS X, iOS and Linux and serves as the foundation for building power

Alsey Coleman Miller 258 Oct 6, 2022
Simple iOS app in Swift to show AQI for some cities using websocket using Combine + MVVM

AQI Simple iOS app in Swift to show AQI for some cities using websocket using Combine + MVVM This app follows MVVM This app uses combine framework The

Amey Vikkram Tiwari 2 Nov 6, 2022
Shawn Frank 2 Aug 31, 2022
MVVM project to show AQI of cities via web socket

Air Quality Monitoring Application Swift project with JSON parsing using codable About the application The app consists of live realtime data from the

Pran Kishore 0 Nov 27, 2021