Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,24 @@ For Cordova 3.x.x:
Usage:
------

This plugin exposes no interface, it simply sets your app to be private. You don't need to do anything except install the plugin.
This plugin exposes no interface in Android, it simply sets your app to be private. You don't need to do anything except install the plugin.

In iOS the privacy screen fades on page load or in a set time interval, if you want more control you have the following functions:
- setTimer(successCallback, errorCallback, timeInterval) : sets timer to make privacy screen fade away (default is 3 seconds and can be set through preference).
- hidePrivacyScreen(successCallback, errorCallback) : Explicitely hides the privacy screen.
- showPrivacyScreen(successCallback, errorCallback) : Explicitely shows the privacy screen (respects timer interval to fade)

For iOS there are 3 preferences that can be set in config.xml:
- "PrivacyOnBackground": If set to "true" allows splashscreen to be shown only when app enters background (i.e. switched to another app or pressed the home button)
- "PrivacyOverrideLaunchImage": If set to "true" allows privacy screen to be the Default image even if LaunchImage is set in the info-plist
- "PrivacyImageName": String for image name, images should be in the app bundle and follow the size naming convention (i.e. for app name "Test", there should be a "Test-667h.png" in the bundle for iPhone 6)
- "PrivacyTimer": accepts a value in seconds for the privacy screen timer

When using splash storyboard add images to the config xml.
(i.e
<splash src="res/screen/ios/LaunchImage@2x~universal~anyany.png" />
<splash src="res/screen/ios/LaunchImage@3x~universal~anyany.png" />
)

Test this plugin on a real device because the iOS simulator (7.1 at least) does a poor job hiding your app.

Expand All @@ -36,4 +53,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-privacyscreen",
"version": "0.3.1",
"version": "0.4.3",
"description": "Secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.",
"cordova": {
"id": "cordova-plugin-privacyscreen",
Expand Down
7 changes: 6 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-privacyscreen" version="0.3.1">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-privacyscreen" version="0.4.3">

<name>PrivacyScreenPlugin</name>
<description>Secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.</description>
<license>MIT</license>

<js-module src="www/PrivacyScreenPlugin.js" name="PrivacyScreenPlugin">
<clobbers target="window.plugins.privacyscreen" />
</js-module>

<platform name="android">

<config-file parent="/*" target="res/xml/config.xml">
Expand Down
18 changes: 18 additions & 0 deletions src/android/PrivacyScreenPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,22 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
Activity activity = this.cordova.getActivity();
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
//Not used in Android
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if ("setTimer".equals(action)) {
callbackContext.success();
return true;
}
else if ("hidePrivacyScreen".equals(action)) {
callbackContext.success();
return true;
}
else if ("showPrivacyScreen".equals(action)) {
callbackContext.success();
return true;
}

return false; // Returning false results in a "MethodNotFound" error.
}
}
7 changes: 6 additions & 1 deletion src/ios/PrivacyScreenPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ typedef struct {
BOOL iPhone6;
BOOL iPhone6Plus;
BOOL retina;
BOOL iPhoneX;

} CDV_iOSDevice;

@interface PrivacyScreenPlugin : CDVPlugin

@end
- (void) setTimer:(CDVInvokedUrlCommand*)command;
- (void) hidePrivacyScreen:(CDVInvokedUrlCommand*)command;
- (void) showPrivacyScreen:(CDVInvokedUrlCommand*)command;

@end
Loading