Added js interface
This commit is contained in:
parent
433e216439
commit
76ada42564
@ -16,6 +16,10 @@
|
|||||||
<engine name="cordova" version=">=3.0.0" />
|
<engine name="cordova" version=">=3.0.0" />
|
||||||
</engines>
|
</engines>
|
||||||
|
|
||||||
|
<js-module src="www/background-mode.js" name="BackgroundMode">
|
||||||
|
<clobbers target="plugin.notification.BackgroundMode" />
|
||||||
|
</js-module>
|
||||||
|
|
||||||
<!-- ios -->
|
<!-- ios -->
|
||||||
<platform name="ios">
|
<platform name="ios">
|
||||||
<config-file target="config.xml" parent="/*">
|
<config-file target="config.xml" parent="/*">
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
@interface APPBackgroundMode : CDVPlugin
|
@interface APPBackgroundMode : CDVPlugin
|
||||||
|
|
||||||
// Aktiviert den Hintergrundmodus
|
// Aktiviert den Hintergrundmodus
|
||||||
- (void) activateMode;
|
- (void) activate:(CDVInvokedUrlCommand *)command;
|
||||||
// Deaktiviert den Hintergrundmodus
|
// Deaktiviert den Hintergrundmodus
|
||||||
- (void) deactivateMode;
|
- (void) deactivate:(CDVInvokedUrlCommand *)command;
|
||||||
|
|
||||||
@property (nonatomic, strong) CLLocationManager* locationManager;
|
@property (nonatomic, strong) CLLocationManager* locationManager;
|
||||||
|
|
||||||
|
@ -9,11 +9,44 @@
|
|||||||
|
|
||||||
#import "APPBackgroundMode.h"
|
#import "APPBackgroundMode.h"
|
||||||
|
|
||||||
|
@interface APPBackgroundMode (PrivateMethods)
|
||||||
|
|
||||||
|
// Aktiviert den Hintergrundmodus
|
||||||
|
- (void) activateMode;
|
||||||
|
// Deaktiviert den Hintergrundmodus
|
||||||
|
- (void) deactivateMode;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation APPBackgroundMode
|
@implementation APPBackgroundMode
|
||||||
|
|
||||||
@synthesize locationManager;
|
@synthesize locationManager;
|
||||||
|
|
||||||
// Aktiviert den Hintergrundmodus
|
/**
|
||||||
|
* @js-interface
|
||||||
|
*
|
||||||
|
* Aktiviert den Hintergrundmodus.
|
||||||
|
*/
|
||||||
|
- (void) activate:(CDVInvokedUrlCommand *)command
|
||||||
|
{
|
||||||
|
[self activateMode];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @js-interface
|
||||||
|
*
|
||||||
|
* Deaktiviert den Hintergrundmodus.
|
||||||
|
*/
|
||||||
|
- (void) deactivate:(CDVInvokedUrlCommand *)command
|
||||||
|
{
|
||||||
|
[self deactivateMode];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @obj-c-interface
|
||||||
|
*
|
||||||
|
* Aktiviert den Hintergrundmodus.
|
||||||
|
*/
|
||||||
- (void) activateMode
|
- (void) activateMode
|
||||||
{
|
{
|
||||||
if (!locationManager) {
|
if (!locationManager) {
|
||||||
@ -30,7 +63,11 @@
|
|||||||
[locationManager startUpdatingLocation];
|
[locationManager startUpdatingLocation];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deaktiviert den Hintergrundmodus
|
/**
|
||||||
|
* @obj-c-interface
|
||||||
|
*
|
||||||
|
* Deaktiviert den Hintergrundmodus.
|
||||||
|
*/
|
||||||
- (void) deactivateMode
|
- (void) deactivateMode
|
||||||
{
|
{
|
||||||
if (locationManager) {
|
if (locationManager) {
|
||||||
@ -38,7 +75,9 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registriert sich für die (sleep/resume) Events und startet bzw. stoppt die Geo-Lokalisierung
|
/**
|
||||||
|
* Registriert die Listener für die (sleep/resume) Events und startet bzw. stoppt die Geo-Lokalisierung.
|
||||||
|
*/
|
||||||
- (void) pluginInitialize
|
- (void) pluginInitialize
|
||||||
{
|
{
|
||||||
if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
|
if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
|
||||||
|
32
www/background-mode.js
Normal file
32
www/background-mode.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* background-mode.js
|
||||||
|
* Cordova Background-Mode Plugin
|
||||||
|
*
|
||||||
|
* Created by Sebastian Katzer (github.com/katzer) on 09/10/2013.
|
||||||
|
* Copyright 2013 Sebastian Katzer. All rights reserved.
|
||||||
|
* GPL v2 licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
var BackgroundMode = function () {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Badge.prototype = {
|
||||||
|
/**
|
||||||
|
* Aktiviert den Hintergrundmodus.
|
||||||
|
*/
|
||||||
|
activate: function () {
|
||||||
|
cordova.exec(null, null, 'BackgroundMode', 'activate', []);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deaktiviert den Hintergrundmodus
|
||||||
|
*/
|
||||||
|
deactivate: function (badge) {
|
||||||
|
cordova.exec(null, null, 'BackgroundMode', 'deactivate', []);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var plugin = new BackgroundMode();
|
||||||
|
|
||||||
|
module.exports = plugin;
|
Loading…
Reference in New Issue
Block a user