Skip to content

Commit 5a5d884

Browse files
committed
Merge pull request #29 from telerik/notify_post
Add notify_post command.
2 parents aaf1fbd + 512500d commit 5a5d884

File tree

9 files changed

+93
-1
lines changed

9 files changed

+93
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ General commands:
5555
launch <full path> Launches the application bundle at the specified path in the iOS Simulator.
5656
device-types Lists the available device types for the current Xcode version.
5757
sdks Lists the available iOS SDK versions.
58+
notify-post Post a darwin notification on a device.
5859

5960
For more information about each command, run
6061
$ isim help <command>

lib/commands/notify-post.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/commands/notify-post.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path=".././.d.ts"/>
2+
"use strict";
3+
4+
import Future = require("fibers/future");
5+
import iphoneSimulatorLibPath = require("./../iphone-simulator");
6+
7+
export class Command implements ICommand {
8+
public execute(args: string[]): IFuture<void> {
9+
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
10+
return iphoneSimulator.sendNotification(args[0]);
11+
}
12+
}

lib/declarations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface IiPhoneSimulator {
55
run(appName: string): IFuture<void>;
66
printDeviceTypes(): IFuture<void>;
77
printSDKS(): IFuture<void>;
8+
sendNotification(notification: string): IFuture<void>;
89
}
910

1011
interface ICommand {

lib/iphone-simulator-xcode-6.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/iphone-simulator-xcode-6.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export class XCode6Simulator implements ISimulator {
3434
config("setDevice", device);
3535
}
3636

37+
public getSimulatedDevice(): any {
38+
return this.getDeviceByIdentifier(this.deviceIdentifier);
39+
}
40+
3741
private getDevicesInfo(): IDevice[] {
3842
return <IDevice[]> _(this.getAvailableDevices())
3943
.map(_.identity)

lib/iphone-simulator.js

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/iphone-simulator.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ export class iPhoneSimulator implements IiPhoneSimulator {
7070
return this.execute(action, { canRunMainLoop: false });
7171
}
7272

73+
public sendNotification(notification: string): IFuture<void> {
74+
if(!notification) {
75+
errors.fail("Notification required");
76+
}
77+
78+
var action = () => {
79+
var simulator = new xcode6SimulatorLib.XCode6Simulator();
80+
var device = simulator.getSimulatedDevice();
81+
82+
if (!device) {
83+
errors.fail("Could not find device");
84+
}
85+
86+
var result = device("postDarwinNotification", $(notification), "error", null);
87+
if (!result) {
88+
errors.fail("Could not send notification: " + notification);
89+
}
90+
};
91+
92+
return this.execute(action, { canRunMainLoop: false });
93+
}
94+
7395
private execute(action: (appPath?: string) => any, opts: IExecuteOptions): IFuture<void> {
7496
$.importFramework(iPhoneSimulator.FOUNDATION_FRAMEWORK_NAME);
7597
$.importFramework(iPhoneSimulator.APPKIT_FRAMEWORK_NAME);

resources/help.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ General commands:
99
launch <full path> Launches the application bundle (.app) at the specified path in the iOS Simulator.
1010
device-types Lists the available device types for the current Xcode version.
1111
sdks Lists the available iOS SDK versions.
12+
notify-post Post a darwin notification on a device.
1213

1314
General options:
1415
--help Prints help about the selected command.
@@ -60,4 +61,14 @@ Usage:
6061

6162
Lists the available iOS SDK versions.
6263

63-
--[/]--
64+
--[/]--
65+
66+
--[notify-post]--
67+
68+
Usage:
69+
$ ios-sim-portable notify-post <notification>
70+
$ isim notify-post <notification>
71+
72+
Posts a darwin notification on a device.
73+
74+
--[/]--

0 commit comments

Comments
 (0)