-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(network-permission): add plugin (#4830)
- Loading branch information
1 parent
8fc3465
commit bff5cce
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/@awesome-cordova-plugins/plugins/network-permission/index.ts
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,44 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core'; | ||
|
||
/** | ||
* @name Network Permission | ||
* @description | ||
* Requires Cordova plugin: cordova-plugin-network-permission. For more info, please see the [Network permission plugin docs](https://github.com/j5int/cordova-plugin-network-permission). | ||
* @usage | ||
* ```typescript | ||
* import { NetworkPermission } from '@awesome-cordova-plugins/network-permission/ngx'; | ||
* | ||
* constructor(private networkPermission: NetworkPermission) { } | ||
* | ||
* ... | ||
* | ||
* this.networkPermission.requestLocalNetworkPermission() | ||
* .then(() => { | ||
* console.log('Permission was granted successful'); | ||
* }) | ||
* .catch(() => { | ||
* console.log('Permission declined'); | ||
* }); | ||
* | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'NetworkPermission', | ||
plugin: 'cordova-plugin-network-permission', | ||
pluginRef: 'localNetworkPermission', | ||
repo: 'https://github.com/j5int/cordova-plugin-network-permission', | ||
platforms: ['iOS'], | ||
}) | ||
@Injectable() | ||
export class NetworkPermission extends AwesomeCordovaNativePlugin { | ||
/** | ||
* Request local network permission | ||
* | ||
* @returns {Promise<boolean>} | ||
*/ | ||
@Cordova() | ||
requestLocalNetworkPermission(): Promise<boolean> { | ||
return; | ||
} | ||
} |