Giter VIP home page Giter VIP logo

srnotification's Introduction

Simple Remote Notification for AppKit

For those who want to send message to your users and do not want to make it through Apple Remote Notification.

Framework uses remote JSON file with message, action URL, time when message should appear and few other options. Library check with time interval you choose, if it found new message there, it will schedule it through local notification system.

How to use SRNotification

1. Add framework to your project: File -> Add Files -> SRNotification project file. Add @loader_path/../Frameworks to build settings Runpath search path.

2. In your AppDelegate add this

@import SRNotification;

3. Add instance variable to hold SRNotification instance:

@property (strong) SRNotification *notification;

4. Later in applicationDidFinishLaunching: (NSNotification *) aNotification:

self.notification = [[SRNotification alloc] init];
[self.notification trackURL:Remote-message-URL  updateInterval:Update-interval-in-seconds startupNotification:aNotification];

For example, for update every hour:

self.notification = [[SRNotification alloc] init];
[self.notification trackURL:[NSURL URLWithString:@"http://mysite.com/remote_message.json"]  updateInterval:60*60 startupNotification:aNotification];

You should pass aNotification object to the framework since if you app is offline, after user click notification, app will be started and message action should be made.

5. Enable alert notifications

If you want do not want your notifications dissapear after several seconds, add key NSUserNotificationAlertStyle and set it to alert into your info.plist.

Format of JSON file

Here is the sample JSON file:

{
    "id" : "15",
    "title" : "Thank you for using my app!",
    "message" : "You can visit our site for more information.",
    "url" : "http://myappsite.com",
    "date" : "2015-01-20 18:23",
    "button" : "Visit",
    "anyway" : true,
    "active" : true
}

Parameters:

id - identifier of the message. Used to distinguish one message from another, when some message was shown, ID is saved and next time this message will not be shown

title - Title of the message.

message - Message text.

url - Where user will be redirected if he press the button.

date - Date when message should be shown converted to GMT.

button - Text on button with action.

anyway - Where message should be shown even if the date is in the past

active - If message is inactive, it will not be shown

Requirements

SRNotification requires AppKit >= 10.9, but could be integrated in any project since 10.6 (but it won't work there)

srnotification's People

Contributors

blackliteon avatar nikolaeu 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.