-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add outsystems javascript wrapper for both capacitor and cordov…
…a plugins
- Loading branch information
Showing
26 changed files
with
9,701 additions
and
4,087 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.outsystems.plugins.osgeolocation"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
import { WebPlugin } from '@capacitor/core'; | ||
|
||
import type { CallbackID, ClearWatchOptions, GeolocationPluginPermissions, IGeolocationPlugin, PermissionStatus, Position, PositionOptions, WatchPositionCallback } from './definitions'; | ||
import type { CallbackID, IGeolocationPlugin, PermissionStatus, Position, PositionOptions, WatchPositionCallback } from './definitions'; | ||
|
||
export class GeolocationPluginWeb extends WebPlugin implements IGeolocationPlugin { | ||
getCurrentPosition(options?: PositionOptions): Promise<Position> { | ||
throw new Error('Method not implemented.'); | ||
async getCurrentPosition(options?: PositionOptions): Promise<Position> { | ||
return new Promise((resolve, reject) => { | ||
navigator.geolocation.getCurrentPosition( | ||
pos => { | ||
resolve(pos); | ||
}, | ||
err => { | ||
reject(err); | ||
}, | ||
{ | ||
enableHighAccuracy: false, | ||
timeout: 10000, | ||
maximumAge: 0, | ||
...options, | ||
}, | ||
); | ||
}); | ||
} | ||
watchPosition(options: PositionOptions, callback: WatchPositionCallback): Promise<CallbackID> { | ||
throw new Error('Method not implemented.'); | ||
|
||
async watchPosition(options: PositionOptions, callback: WatchPositionCallback): Promise<CallbackID> { | ||
const id = navigator.geolocation.watchPosition( | ||
pos => { | ||
callback(pos); | ||
}, | ||
err => { | ||
callback(null, err); | ||
}, | ||
|
||
{ | ||
enableHighAccuracy: false, | ||
timeout: 10000, | ||
maximumAge: 0, | ||
minimumUpdateInterval: 5000, | ||
...options, | ||
}, | ||
); | ||
|
||
return `${id}`; | ||
} | ||
clearWatch(options: ClearWatchOptions): Promise<void> { | ||
throw new Error('Method not implemented.'); | ||
async clearWatch(options: { id: string }): Promise<void> { | ||
navigator.geolocation.clearWatch(parseInt(options.id, 10)); | ||
} | ||
checkPermissions(): Promise<PermissionStatus> { | ||
throw new Error('Method not implemented.'); | ||
|
||
async checkPermissions(): Promise<PermissionStatus> { | ||
if (typeof navigator === 'undefined' || !navigator.permissions) { | ||
throw this.unavailable('Permissions API not available in this browser'); | ||
} | ||
|
||
const permission = await navigator.permissions.query({ | ||
name: 'geolocation', | ||
}); | ||
return { location: permission.state, coarseLocation: permission.state }; | ||
} | ||
requestPermissions(permissions?: GeolocationPluginPermissions): Promise<PermissionStatus> { | ||
throw new Error('Method not implemented.'); | ||
|
||
async requestPermissions(): Promise<PermissionStatus> { | ||
throw this.unimplemented('Not implemented on web.'); | ||
} | ||
} | ||
|
||
const Geolocation = new GeolocationPluginWeb(); | ||
|
||
export { Geolocation }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,4 @@ node_modules/ | |
|
||
# Generated by Cordova | ||
/plugins/ | ||
/platforms/ | ||
dist/ | ||
/platforms/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ClearWatchOptions, CurrentPositionOptions, WatchPositionOptions } from './definitions'; | ||
|
||
export declare const CurrentPositionOptionsDefault: CurrentPositionOptions; | ||
export declare const ClearWatchOptionsDefault: ClearWatchOptions; | ||
export declare const WatchPositionOptionsDefault: WatchPositionOptions; |
Oops, something went wrong.