Coder Social home page Coder Social logo

openstack-mobile / bsforegroundnotification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kunass2/foregroundnotification

2.0 4.0 0.0 6.8 MB

Present your custom iOS 10 notification when app is in foreground mode.

License: MIT License

Ruby 2.80% Swift 63.81% Objective-C 2.02% Shell 31.37%

bsforegroundnotification's Introduction

BSForegroundNotification

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

BSForegroundNotification is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "BSForegroundNotification"

If you used use_framework in your podfile just simply do:

import BSForegroundNotification

for every file when you need to use it.

you may also use:

@import BSForegroundNotification

within bridging header file and avoid to import framework for every needed file.

##Info

  • entirely written in latest Swift syntax. Works with iOS 8 and 9 and Xcode7.
  • to present local foreground notification, both alertTitle and alertBody cannot be nil
  • to present remote foreground notification, both title and body cannot be nil in alert dictionary. In case when alert is a string, that string cannot be empty.

##Usage

######Simply create your foreground notification object with on of three ways:

let notification = BSForegroundNotification(userInfo: userInfo) //remote
let notification = BSForegroundNotification(localNotification: localNotification) //local
let notification = BSForegroundNotification(titleLabel: "title", subtitleLabel: "subtitle", categoryIdentifier: "category") //custom initializer

######Set a default dismissal time for the notification:

notification.timeToDismissNotification = 10 //4 is by default

######Set delegate which conform to protocol BSForegroundNotificationDelegate:

Note that BSForegroundNotificationDelegate inherits from UIApplicationsDelegate

notification.delegate = self

######Implement optional methods of BSForegroundNotificationDelegate

@objc public protocol BSForegroundNotificationDelegate: class, UIApplicationDelegate {

    optional func foregroundRemoteNotificationWasTouched(with userInfo: [AnyHashable: Any])
    optional func foregroundLocalNotificationWasTouched(with localNotification: UILocalNotification)
}

######Then present notification:

notification.presentNotification()

######If it is needed one of BSForegroundNotificationDelegate's method is called':

func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable: Any], completionHandler: () -> Void)
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable: Any], withResponseInfo responseInfo: [AnyHashable: Any], completionHandler: () -> Void)
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, completionHandler: () -> Void)
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, withResponseInfo responseInfo: [AnyHashable: Any], completionHandler: () -> Void)

######Class properties:

You can set your own sound using systemSoundID class property:

BSForegroundNotification.systemSoundID = 1002 //1001 is by default

Author

Bartłomiej Semańczyk, [email protected]

License

BSForegroundNotification is available under the MIT license. See the LICENSE file for more info.

bsforegroundnotification's People

Contributors

dilizarov avatar heygul avatar kunass2 avatar thebehera avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.