Swift library to manage in app notification in swift language, like WhatsApp, Telegram, Frind, ecc.

Overview

InAppNotify - Manage in App notifications

InAppNotify

Version License Platform Swift3

During develop of my app Frind, I needed to manage in app notifications like whatsapp or telegram, but i didn't find nothing that liked me, so, i created this library. Choose InAppNotify for your next project, I'll be happy to give you a little help!

★★ Star our github repository to help us!, or pay me a coffee ★★

Created by Luca Becchetti

Screenshots

Requirements

  • iOS 8+
  • swift 4.0

Main features

Here's a highlight of the main features you can find in InAppNotify:

  • Multiple orientation We support portrait and landscape orientation
  • Fully customizable. You can customize all programmatically
  • Swipe gesture Up to dismiss, or down to show reply text field

You also may like

Do you like InAppNotify? I'm also working on several other opensource libraries.

Take a look here:

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like InAppNotify in your projects. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate InAppNotify into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
  use_frameworks!
  pod 'InAppNotify'
end

Then, run the following command:

$ pod install

How to use

First of all import library in your project

import InAppNotify

The basic code to show a simple notification is:

//If you are in a UIViewController
InAppNotify.Show(Announcement(title: "Hello world! my first example!"), to: self)

InAppNotify.Show method

This is a static method used to present a notitication, it takes two parameters, first is an instance of Announcement object, the second is a subclass of UIViewController

Create announcement object

This library can show only an instance of "Announcement" object, you can pass many parameters to his initializer:

let announce = Announcement(
      //Title, the first line
      title           : "I am titile",
      //Subtitle, the second line
      subtitle        : "I am subititle",
      //Image local, show if no urlImage is set
      image           : UIImage(named: "test"),
      //URL of remote image
      urlImage        : "https://.....",
      //Seconds before disappear
      duration        : 3,
      //Interaction type. none or text
      interactionType : InteractionType.none,
      //Pass data to annoucement
      userInfo        : ["id" : 10],
      //Action callback
      action: { (type, string, announcement) in
                
            //You can detect the action by test "type" var     
            if type == CallbackType.tap{
                  print("User has been tapped")
            }else if type == CallbackType.text{
                  print("Reply from notification: \(string!)")
            }else{
                  print("Notification has been closed!")
            }
      }
            
)

Present announcement object

When object is created you can present it with this code:

//If you are in a UIViewController
InAppNotify.Show(announce, to: self)

Interact with notification

When you create an announcement, you can interact with it passed an action callback:

//Inside initialization of announcement
action: { (type, string, announcement) in
                
  //You can detect the action by test "type" var     
  if type == CallbackType.tap{
    print("User has been tapped")
  }else if type == CallbackType.text{
    print("Reply from notification: \(string!)")
  }else{
    print("Notification has been closed!")
  }
  
}

From the callbacak you can access the announcement object that has been triggered this method, announcement has a particolar attribute called "userInfo" (it's of type "Any") that you can set when create object, and read here.

If you want to enable a textField interaction when pull down notification, pass this parameter to announcement object:

//Inside initialization of announcement
interactionType : InteractionType.text,

This will present a textArea where user can write! to modify the text button ("send" by default) use this code:

InAppNotify.sendString = "Send"

To read user input, if you have set an action callback, test if the type is "text" and access string variable:

//Inside callback
if type == CallbackType.text{
    print("Reply from notification: \(string!)")
}

Customization

InAppNotify supports themes, by default we have two themes, accessibile from "Themes" class:

  • Themes.dark
  • Themes.light

To use a theme you have to set a global variable of the library, example:

//Set dark theme
InAppNotify.theme = Themes.dark

Of course, you can create your custom theme programmatically, here an example:

//Create and use a custom theme
InAppNotify.theme = Theme(
      titleFont                   : UIFont.boldSystemFont(ofSize: 18),
      subtitleFont                : UIFont.systemFont(ofSize: 13),
      backgroundColor             : UIColor(red:0.90, green:0.58, blue:0.15, alpha:1.00),
      dragIndicatorColor          : UIColor(red:0.95, green:0.80, blue:0.19, alpha:1.00),
      titleColor                  : UIColor.white,
      subtitleColor               : UIColor.white,
      shadowColor                 : UIColor.darkGray.cgColor,
      inputTextBackgroundColor    : UIColor(red:0.95, green:0.80, blue:0.19, alpha:1.00),
      inputTextColor              : UIColor.white,
      sendButtonHighlightedColor  : UIColor.darkGray,
      sendButtonNormalColor       : UIColor.black,
      separatorLineColor          : UIColor.black
)

Projects using InAppNotify

Your App and InAppNotify

I'm interested in making a list of all projects which use this library. Feel free to open an Issue on GitHub with the name and links of your project; we'll add it to this site.

Credits & License

InAppNotify is owned and maintained by Luca Becchetti

As open source creation any help is welcome!

The code of this library is licensed under MIT License; you can use it in commercial products without any limitation.

The only requirement is to add a line in your Credits/About section with the text below:

In app notification by InAppNotify - http://www.lucabecchetti.com
Created by Becchetti Luca and licensed under MIT License.

About me

I am a professional programmer with a background in software design and development, currently developing my qualitative skills on a startup company named "Frind " as Project Manager and ios senior software engineer.

I'm high skilled in Software Design (10+ years of experience), i have been worked since i was young as webmaster, and i'm a senior Php developer. In the last years i have been worked hard with mobile application programming, Swift for ios world, and Java for Android world.

I'm an expert mobile developer and architect with several years of experience of team managing, design and development on all the major mobile platforms: iOS, Android (3+ years of experience).

I'm also has broad experience on Web design and development both on client and server side and API /Networking design.

All my last works are hosted on AWS Amazon cloud, i'm able to configure a netowrk, with Unix servers. For my last works i configured apache2, ssl, ejabberd in cluster mode, Api servers with load balancer, and more.

I live in Assisi (Perugia), a small town in Italy, for any question, contact me

You might also like...
Display Apple system-like self-hiding status alerts. It is well suited for notifying user without interrupting user flow in iOS-like way.
Display Apple system-like self-hiding status alerts. It is well suited for notifying user without interrupting user flow in iOS-like way.

StatusAlert is being sponsored by the following tool; please help to support us by takin a look and signing up to a free trial. Dependency managers Fe

Animated alert library like Swarm app.
Animated alert library like Swarm app.

TKSwarmAlert Animation Tool for Alert like Swarm app. ScreenShot Installation CocoaPods You can use CocoaPods to install TKSwarmAlert by adding it to

An iOS library for SwiftUI to create draggable sheet experiences similar to iOS applications like Maps and Stocks.

An iOS library for SwiftUI to create draggable sheet experiences similar to iOS applications like Maps and Stocks.

DropView - A SwiftUI library to display Apple Pencil and Pasteboard-like alerts on iOS.
DropView - A SwiftUI library to display Apple Pencil and Pasteboard-like alerts on iOS.

DropView is a SwiftUI-based library to display alerts inspired by the Apple Pencil and pasteboard stock ones.

A Google like action sheet for iOS written in Swift.
A Google like action sheet for iOS written in Swift.

MaterialActionSheetController Lightweight and totally customizable. Create and present it the way you do with UIAlertController. Screenshots Demo | De

A µFramework for showing alerts like the one used when copying from pasteboard or connecting Apple pencil
A µFramework for showing alerts like the one used when copying from pasteboard or connecting Apple pencil

Drops 💧 A µFramework for showing alerts like the one used when copying from pasteboard or connecting Apple pencil. Features iOS 10+ Can be used in Sw

Create Apple-like alerts & toasts using SwiftUI
Create Apple-like alerts & toasts using SwiftUI

AlertToast-SwiftUI Present Apple-like alert & toast in SwiftUI 🌄 Example 🔭 Overview Currently in SwiftUI, the only way to inform the user about some

This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner
This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner

RMDateSelectionViewController This framework allows you to select a date by presenting an action sheet. In addition, it allows you to add actions arro

This is an iOS control for presenting any UIView in an UIAlertController like manner
This is an iOS control for presenting any UIView in an UIAlertController like manner

RMActionController This framework allows you to present just any view as an action sheet. In addition, it allows you to add actions around the present

Comments
  • How can I display my APNS notification with InAppNotify while in app?

    How can I display my APNS notification with InAppNotify while in app?

    Hello! Recently, I installed InAppNotify and tried to use it to handle the function 'didReceiveRemoteNotification' like this in AppDelegate :

        func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
            guard let vc = PresentingViewController.shared, // A special way to get the presenting vc
            let content = userInfo["aps"] as? [String:Any],
            let alert = content["alert"] as? [String:String],
            let title = alert["title"],
            let subTitle = alert["subtitle"],
            let imageUrl = alert["image"] else { return }
            let announcement = Announcement(title: title, subtitle: subTitle, image: nil, urlImage: imageUrl, duration: 3, interactionType: .none, userInfo: nil, action: nil)
            InAppNotify.Show(announcement, to: vc)
        }
    

    However, the notify isn't showed after this, could you please help me find out my mistakes?

    opened by weitcis 6
  • Argument of '#selector' refers to instance method that is not exposed to Objective-C

    Argument of '#selector' refers to instance method that is not exposed to Objective-C

    • Argument of '#selector' refers to instance method 'orientationDidChange()' that is not exposed to Objective-C
    • Argument of '#selector' refers to instance method 'displayTimerDidFire()' that is not exposed to Objective-C

    Add '@objc' to expose this instance method to Objective-C

    opened by mariohercules 3
  • Minor rotation issue

    Minor rotation issue

    Nice work Luca. While you have support for rotation, I noticed that the textView does not size to max width of the screen, when you rotate the iPad, while the notification is displayed.

    IF you go from Landscapre to Portrait that will cause the Send button to hide. landscape portrait

    opened by ServicePal 2
Owner
Luca Becchetti
I am a professional programmer with a background in software design and development, currently developing my qualitative skills on a startup company "Brokenice"
Luca Becchetti
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 26, 2022
A crisp in-app notification/message banner built in Swift.

RMessage Screenshots Intro Welcome to RMessage! RMessage is a simple notification library written in Swift to help you display notification on the scr

Adonis Peralta 407 Nov 29, 2022
In-app notification in Swift, with customizable buttons and input text field.

Notie Undistracted in-app notification in Swift, with added buttons and input box. Installation CocoaPods To integrate Notie into your Xcode project u

Thi Doãn 85 Aug 8, 2020
The easiest way to display highly customizable in app notification banners in iOS

Written in Swift 5 NotificationBanner is an extremely customizable and lightweight library that makes the task of displaying in app notification banne

Dalton Hinterscher 4.5k Jan 9, 2023
Highly customizable alertview and alert/notification/success/error/alarm popup written in Swift

CDAlertView is highly customizable alert popup written in Swift. Usage is similar to UIAlertController. Screenshots Animations Usage Basic usage witho

Candost Dagdeviren 1.1k Dec 30, 2022
A lightweight dropdown notification for iOS 7+, in Swift.

BRYXBanner A lightweight dropdown banner for iOS 7+. Usage Import BRYXBanner import BRYXBanner Create a banner using the designated initializer. let b

Bryx, Inc 1k Nov 20, 2022
A modern iOS toast view that can fit your notification needs

CRToast CRToast is a library that allows you to easily create notifications that appear on top of or by pushing out the status bar or navigation bar.

Collin Ruffenach 4.2k Dec 30, 2022
Emulates the native Remote Notification View.

Introduction HDNotificationView appears notification view like system. Requirement iOS 9.0+ Installation Carthage github "nhdang103/HDNotificationView

Nguyen Hai Dang 357 Nov 20, 2022
A simple and attractive AlertView to ask permission to your users for Push Notification.

A simple and attractive AlertView **to ask permission to your users for Push Notification.** PRESENTATION Ask permission to user for push notification

Boisney Philippe 37 Mar 23, 2022
OEANotification is a customizable notification view framework

OEANotification OEANotification is an iOS library which provides to create notifications and customize them easily. You can create notifications with

Ömer Aslan 19 Jan 30, 2021