• Stars
    star
    199
  • Rank 194,921 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library for generic presentation of "banners" (e.g. to present a push notification) from anywhere inside an iOS app.

Why?

Apple doesn't provide an API in iOS for presenting notification banners while the app is running. For many projects the most sensible way to respond to a remote push notification would be to display that notification (in the same style it is presented if your app is not foreground) and allow the user to determine whether the notification merits a response.

What?

JCNotificationBannerPresenter allows you to display notification banners asynchronously from any piece of code in your application. It is not view/view-controller specific, you can use it directly from the AppDelegate, for example. It doesn't attempt to mimic the style of Apple's notifications; it seems better to avoid the uncanny valley presented by that endeavor. Just like Apple's notifications, however, this project slides down a banner from the middle of the status bar that times out after a set period of time and slides back up. The banner also can be dismissed by tapping on it, and a custom tap handler can be assigned to trigger some custom action.

Usage?

#import "JCNotificationCenter.h"

…

- (void) application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)notification {
  NSString* title = @"Push Notification";
  NSDictionary* aps = [notification objectForKey:@"aps"];
  NSString* alert = [aps objectForKey:@"alert"];
  [JCNotificationCenter
   enqueueNotificationWithTitle:title
   message:alert
   tapHandler:^{
     NSLog(@"Received tap on notification banner!");
   }];
}

By default the banner style is iOS style, which presents banners with a 3D rotation. The project comes with an alternative Smoke appearance, which slides a semi-translucent window down from the status bar. If you want to use the same style for all notifications in your project, you can set the style at compile time by overriding or editing the +presenterClass method in JCNotificationCenter.

Notifications enqueued with the method +enqueueNotificationWithTitle:message:tapHandler: will time out in five seconds. You can change this on a per-notification basis by setting the timeout property in JCNotificationBanner and enqueing the banner with -enqueueNotification:. A value <= 0 will never timeout and requires user interaction to dismiss.

Installation?

This project includes a podspec for usage with CocoaPods. Simply add

pod 'JCNotificationBannerPresenter'

to your Podfile and run pod install.

Alternately, you can configure your project to include the QuartzCore (CoreGraphics already includes QuartzCore ) framework and add all of the .h and .m files in this project. If your project does not use ARC, you will need to enable ARC on these files. You can enabled ARC per-file by adding the -fobjc-arc flag, as described on a common StackOverflow question.

License

This project is licensed under the MIT license. All copyright rights are retained by myself.

Copyright (c) 2012 James Coleman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

tomcat-redis-session-manager

Redis-backed non-sticky session store for Apache Tomcat
Java
1,794
star
2

JCAutocompletingSearch

iOS widget for querying asynchronous backends allowing user selection from results.
Objective-C
153
star
3

mail_alternatives_with_attachments

Send multipart alternative emails with attachments from ActionMailer
Ruby
20
star
4

JCActivityBar

View-specific (rather than per-window) activity info bar.
Objective-C
19
star
5

homebridge-lutron-caseta

Homebridge plugin for integration with the Lutron Caseta Smart Bridge Pro
JavaScript
10
star
6

ada-keyboard

Column-staggered split keyboard with sane thumb clusters
JavaScript
8
star
7

RelationalScopeQueryPlugin

Relationally scoped query plugin for GORM and Hibernate
Groovy
7
star
8

JCDefaultFormInputAccessoryView

Default input accessory view for iOS with next/previous and done buttons.
Objective-C
4
star
9

JSON-Audit

Find out how much of the JSON you return is actually used by your RIA JS.
JavaScript
4
star
10

relation_to_struct

Return struct results from ActiveRecord relation queries
Ruby
4
star
11

Simulator8086

Simulator for CpS310 of the Intel 8086 and some surrounding hardware. Designed not necessarily for the fastest execution, but to demonstrate the various parts of the 8086 in a very clear conceptual presentation.
Ruby
3
star
12

opsworks-layer-json-attributes-cookbook

Configures per-layer node attributes via Opsworks Stack-level custom JSON
Ruby
3
star
13

postgres-dev-tools

Scripts to make hacking on Postgres easier.
Shell
2
star
14

GraphemeMapper

A radical rethinking of ORM for Groovy/JVM languages.
Groovy
2
star
15

rails_admin_phone_number_field

Adds a auto-formatting phone number field to RailsAdmin.
Ruby
2
star
16

PongOS

Bootable graphical pong written completely in assembly for CpS 230 Computer Systems
Assembly
2
star
17

Split-Brain-Recovery

Talk about using pg_waldump and pg_rewind to inspect a split brain and recovery from it
Shell
1
star
18

git-pull-request-scripts

Ruby
1
star
19

compiler-class-project

Semester project for senior university compiler class
Java
1
star
20

jQuery-Taggable-Input

A lΓ‘ Facebook status update input.
JavaScript
1
star
21

batched_relations

Performantly batch ActiveRecord relation queries
Ruby
1
star
22

Sim86-Testing-Server

Node.JS based testing backend for the Simulator8086 project
JavaScript
1
star