mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-12-23 13:57:35 +00:00
Added js interface
This commit is contained in:
parent
433e216439
commit
76ada42564
@ -16,6 +16,10 @@
|
||||
<engine name="cordova" version=">=3.0.0" />
|
||||
</engines>
|
||||
|
||||
<js-module src="www/background-mode.js" name="BackgroundMode">
|
||||
<clobbers target="plugin.notification.BackgroundMode" />
|
||||
</js-module>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
|
@ -14,9 +14,9 @@
|
||||
@interface APPBackgroundMode : CDVPlugin
|
||||
|
||||
// Aktiviert den Hintergrundmodus
|
||||
- (void) activateMode;
|
||||
- (void) activate:(CDVInvokedUrlCommand *)command;
|
||||
// Deaktiviert den Hintergrundmodus
|
||||
- (void) deactivateMode;
|
||||
- (void) deactivate:(CDVInvokedUrlCommand *)command;
|
||||
|
||||
@property (nonatomic, strong) CLLocationManager* locationManager;
|
||||
|
||||
|
@ -9,11 +9,44 @@
|
||||
|
||||
#import "APPBackgroundMode.h"
|
||||
|
||||
@interface APPBackgroundMode (PrivateMethods)
|
||||
|
||||
// Aktiviert den Hintergrundmodus
|
||||
- (void) activateMode;
|
||||
// Deaktiviert den Hintergrundmodus
|
||||
- (void) deactivateMode;
|
||||
|
||||
@end
|
||||
|
||||
@implementation APPBackgroundMode
|
||||
|
||||
@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
|
||||
{
|
||||
if (!locationManager) {
|
||||
@ -30,7 +63,11 @@
|
||||
[locationManager startUpdatingLocation];
|
||||
}
|
||||
|
||||
// Deaktiviert den Hintergrundmodus
|
||||
/**
|
||||
* @obj-c-interface
|
||||
*
|
||||
* Deaktiviert den Hintergrundmodus.
|
||||
*/
|
||||
- (void) deactivateMode
|
||||
{
|
||||
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
|
||||
{
|
||||
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