Merge pull request #656 from NativeScript/notifications

Notifications
This commit is contained in:
Rossen Hristov
2015-09-02 09:15:04 +03:00
6 changed files with 30 additions and 34 deletions

View File

@@ -10,7 +10,7 @@ global.moduleMerge(commonTests, exports);
// ``` JavaScript
//// Add the notification observer
if (app.ios) {
app.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification,
var observer = app.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification,
function onReceiveCallback(notification: NSNotification) {
var percent = UIDevice.currentDevice().batteryLevel * 100;
var message = "Battery: " + percent + "%";
@@ -19,7 +19,7 @@ if (app.ios) {
}
//// When no longer needed, remove the notification observer
if (app.ios) {
app.ios.removeNotificationObserver(UIDeviceBatteryLevelDidChangeNotification);
app.ios.removeNotificationObserver(observer, UIDeviceBatteryLevelDidChangeNotification);
}
// ```
// </snippet>