You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cordova-plugin-network-permission

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-network-permission

Network Access Permission Request for Cordova Apps

1.0.3
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

Cordova Network Permission

This plugin helps to request the network permission from iOS 14 and above.

Problem

There is no api from Apple that allows synchronously to check if the local network permission is granted. Instead, it will pop up the dialog on first attempt but the app will receive connection errors until the user confirms the permission. This is annoying since it can get your app into a state that it can't recover from.

Solution

The native code comes from this stackoverflow thread. Credit to @iUrii https://stackoverflow.com/questions/63940427/ios-14-how-to-trigger-local-network-dialog-and-check-user-answer

This plugin sends a dummy udp package which force the dialog to pop up. It then keeps checking the status. Once the user has either accepted or declined the plugin feeds back to the javascript.

This allows to check this permission synchronous.

Current supported platforms

  • iOS 14 or higher.

It has only been tested on iOS 15.4.1

Installation

Just add the cordova plugin to your project

cordova plugin add https://github.com/j5int/cordova-plugin-network-permission

Use

window.localNetworkPermission.requestLocalNetworkPermission(function () {
    console.info('Permission was granted successful')
}, function (error) {
    // error is string "Permission declined"
    console.error('Permission declined');
});

Keywords

cordova

FAQs

Package last updated on 16 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts