• Stars
    star
    1,373
  • Rank 34,254 (Top 0.7 %)
  • Language
    Objective-C
  • License
    BSD 2-Clause "Sim...
  • Created almost 12 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

Library to send mock remote notifications to the iOS simulator

SimulatorRemoteNotifications

SimulatorRemoteNotifications is a library to send mock remote notifications to the iOS simulator.

The library extends UIApplication by embedding a mini server that listen for UDP packets containing JSON-formated payload, and a service to send notifications to the mini server.

This project includes the iOS Simulator Notifications MacOSX app to help you send the mock notifications.

Note that SimulatorRemoteNotifications does not send notification through Apple's Push Service.

Build Status Cocoapods

Install

Install with CocoaPods

Add a pod entry to your Podfile:

pod 'SimulatorRemoteNotifications', '~> 0.0.3'

Install the pod(s) by running:

pod install

Install the static library

  1. Copy the project file in your project
  2. Link your binary with the library, under Target > Build Phases > Link binary with libraries then add the libSimulatorRemoteNotifications.a
  3. set OTHER_LINKER_FLAGS="-ObjC" for your target

Install manually

  1. clone this repository
  2. add the files in the SimulatorRemoteNotifications directory to your project
  3. set OTHER_LINKER_FLAGS="-ObjC" for your target

Usage

Listening for mock remote notifications

First add #import "UIApplication+SimulatorRemoteNotifications.h" to your application delegate.

Then implement either application:didReceiveRemoteNotification: or application:didReceiveRemoteNotification:fetchCompletionHandler: (background notification, iOS7).

Finally call start listening for mock remote notifications:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

	...

	#if DEBUG
		[application listenForRemoteNotifications];
	#endif

	return YES;
}

When listenForRemoteNotifications is called, application:didRegisterForRemoteNotificationsWithDeviceToken: receives a token in the following format instead of random characters: simulator-remote-notification=IP:PORT

The default port number is 9930. If you want to change the port, use setRemoteNotificationsPort before calling listenForRemoteNotifications:

application.remoteNotificationsPort = 1234;

Now, to send a remote notification, send an udp packet to localhost:9930.

Note that if you send a notification while the app is in the background, application:didReceiveRemoteNotification:fetchCompletionHandler: will only be called when you bring the app to the foreground.

Sending a mock remote notification with the iOS Simulator Notifications app

The project comes with a OSX app called iOS Simulator Notifications to help you send notifications to the iOS Simulator.

Build and run the target and you'll have a nice interface to send notification to your app in the simulator (see screenshots).

Sending a mock remote notification in tests

First add #import "ACSimulatorRemoteNotificationsService.h" to your test

Send you notification with

[[ACSimulatorRemoteNotificationsService sharedService] send:@{@"message":@"message"}];

You can change the host (default: 127.0.0.1) and port (default: 9930) with

[[ACSimulatorRemoteNotificationsService sharedService] setRemoteNotificationsPort:1234];
[[ACSimulatorRemoteNotificationsService sharedService] setRemoteNotificationsHost:@"10.0.0.1"];

Sending a mock remote notification from the command line

You can also send mock remote notifications from the terminal by using netcat:

echo -n '{"message":"message"}' | nc -4u -w1 localhost 9930

Screenshot

screenshots screenshots

Examples

You can look at SimulatorRemoteNotifications.xcodeproj for examples:

  • in SimulatorRemoteNotificationsExample, the application:didReceiveRemoteNotification: method is called
  • in SimulatorRemoteNotificationsBackgroundExample, the application:didReceiveRemoteNotification:fetchCompletionHandler: method is called

Documentation

If you have appledoc installed, you can generate the documentation by running the corresponding target.

Note

(Real) Apple remote notifications are limited to 256 bytes content length.

More Repositories

1

Parallax

Parallax is an iOS library that reproduces the parallax effect of the iOS7 home screen.
Objective-C
407
star
2

ACReuseQueue

A queue to keep and reusing objects.
Objective-C
369
star
3

ACCodeSnippetRepositoryPlugin

A plugin for Xcode to synchronize code snippets with repositories
Objective-C
330
star
4

iOS-MagnifyingGlass

A magnifying glass for iOS
Objective-C
314
star
5

Populate

Populate is both an iOS app and library to easily create random-generated contacts.
Objective-C
120
star
6

instagram-filters

Instagram-like image filters
Python
116
star
7

ACKeyboard

ACKeyboard is a keyboard extension for iOS that mimics the system keyboard, except it has only one 'letter' key: "yo".
Objective-C
104
star
8

flask-autodoc

Flask autodoc automatically creates an online documentation for your flask application.
Python
98
star
9

Segway

Segway is an iOS library for segues but without storyboards.
Objective-C
65
star
10

WebScraper

iOS library for web scraping
Objective-C
37
star
11

ACHalloween

A library with halloween-themed animations for iOS.
Objective-C
21
star
12

xcode-snippets

A set of custom code snippets for Xcode
Objective-C
20
star
13

iOS-Konami-Code

Objective-C
11
star
14

kanjinetworks

kanjinetworks is an interface for the Kanji Networks database.
Python
5
star
15

Spyglass

Events tracking analytics for iOS
Objective-C
4
star
16

NetBrowser

Proof-of-concept: Bonjour services browser
Objective-C
4
star
17

WidgetStoreProduct

Proof of concept: A SKStoreProductViewController replacement using iTunes web widgets
Objective-C
4
star
18

Delirium

Objective-C
4
star
19

Tumblr-backup

Make a local backup of your Tumblr blogs
Shell
3
star
20

esp8266_ddc

C++
3
star
21

gittime

Estimate time spend coding based on commits in a git repository.
Python
2
star
22

Hourglass

iOS library for testing if a time interval is elapsed
Objective-C
2
star
23

lldb_screengraph

LLDB script for creating (dot/graphviz) graphs of iOS screens based on breakpoints.
Python
2
star
24

maskcomp

Maskcomp is a library utility to compare two images, like iPhone screenshots, optionally with a mask.
Python
2
star
25

MultipleStoresTests

Testing multiple persistence store; one in the main bundle and one in the documents directory
Objective-C
1
star
26

IGInterfaceDataTable

Easily build WatchKit tables with complex data structures.
Objective-C
1
star
27

cpp_project_template

CMake
1
star
28

Janus

Proof of concept for building a "multiversal" (x86+arm) fat binary
Objective-C
1
star
29

jquery.formable

JavaScript
1
star
30

tourofcpp

Quick self-practice of C++11 based on the "A Tour of C++" book.
C++
1
star
31

pkunk.com

JavaScript
1
star
32

AsyncTestKit

iOS library for testing asynchronous operations
Objective-C
1
star
33

clang-tutorial

C++
1
star
34

sample-images

Sample images for various uses, resized to iphone and ipad screen sizes.
1
star
35

tome

HTML
1
star
36

WebViewsTests

Test web views performance with sunspider
JavaScript
1
star
37

MessagingTests

Proof of concept: Messing with Objective-C runtime's messages routing
Objective-C
1
star
38

SimulatorPushNotifications

Moved to https://github.com/acoomans/SimulatorRemoteNotifications
1
star