com.coopbank.mcoopcash50uninstallapp
v0.0.1
Published
App Migration Helper - Detect Old app , if installed prompt uninstall
Maintainers
Readme
Cordova Old App Detector Plugin
A Cordova plugin to detect if an old version of your app is installed on the device and prompt users to uninstall it. This is useful when migrating from an old app package to a new one.
Installation
cordova plugin add cordova-plugin-oldapp-detectorOr install from a local directory:
cordova plugin add /path/to/cordova-plugin-oldapp-detectorSupported Platforms
- Android
- iOS
Usage
Check if Old App is Installed
Check if a specific app (by package name) is installed on the device:
document.addEventListener('deviceready', function() {
var oldPackageName = 'com.example.oldapp';
cordova.plugins.OldAppDetector.isOldAppInstalled(
oldPackageName,
function(isInstalled) {
if (isInstalled) {
console.log('Old app is installed');
// Show a custom message or prompt uninstall
} else {
console.log('Old app is not installed');
}
},
function(error) {
console.error('Error checking old app:', error);
}
);
});Prompt User to Uninstall Old App
Display a native prompt asking the user to uninstall the old app:
document.addEventListener('deviceready', function() {
var oldPackageName = 'com.example.oldapp';
cordova.plugins.OldAppDetector.promptUninstall(
oldPackageName,
function(result) {
console.log('Uninstall prompt shown successfully');
// The user will be taken to the app settings or uninstall screen
},
function(error) {
console.error('Error showing uninstall prompt:', error);
}
);
});Complete Example
Here's a complete workflow for detecting and prompting uninstall:
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
checkForOldApp();
}
function checkForOldApp() {
var oldPackageName = 'com.example.oldapp';
// First, check if old app exists
cordova.plugins.OldAppDetector.isOldAppInstalled(
oldPackageName,
function(isInstalled) {
if (isInstalled) {
// Show custom alert or dialog
if (confirm('We detected an old version of this app. Would you like to uninstall it?')) {
promptUninstallOldApp(oldPackageName);
}
}
},
function(error) {
console.error('Error:', error);
}
);
}
function promptUninstallOldApp(packageName) {
cordova.plugins.OldAppDetector.promptUninstall(
packageName,
function(result) {
console.log('User taken to uninstall screen');
},
function(error) {
console.error('Could not open uninstall screen:', error);
}
);
}API Reference
isOldAppInstalled(packageName, successCallback, errorCallback)
Checks if an app with the specified package name is installed.
Parameters:
packageName(string): The package name of the old app to check- Android example:
'com.example.oldapp' - iOS example:
'oldapp://'(URL scheme)
- Android example:
successCallback(function): Called with a boolean valuetrueif the app is installedfalseif the app is not installed
errorCallback(function): Called if an error occurs
Example:
cordova.plugins.OldAppDetector.isOldAppInstalled(
'com.example.oldapp',
function(isInstalled) {
console.log('Installed:', isInstalled);
},
function(error) {
console.error('Error:', error);
}
);promptUninstall(packageName, successCallback, errorCallback)
Opens the native uninstall screen for the specified app.
Parameters:
packageName(string): The package name of the app to uninstall- Android example:
'com.example.oldapp' - iOS example: Opens app settings (iOS doesn't allow programmatic uninstall)
- Android example:
successCallback(function): Called when the uninstall screen is successfully openederrorCallback(function): Called if an error occurs
Example:
cordova.plugins.OldAppDetector.promptUninstall(
'com.example.oldapp',
function(result) {
console.log('Uninstall screen opened');
},
function(error) {
console.error('Error:', error);
}
);Platform-Specific Notes
Android
- Uses
PackageManagerto check if an app is installed - Opens the app details settings page where users can uninstall the app
- Requires no special permissions
iOS
- Uses URL schemes to detect if an app can be opened
- You need to know the URL scheme of the old app (e.g.,
oldapp://) - On iOS, you cannot programmatically uninstall apps, so
promptUninstallwill open the app settings - You may need to add the URL scheme to your
Info.plistunderLSApplicationQueriesSchemes
Info.plist configuration for iOS:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>oldapp</string>
</array>Use Cases
- App Rebranding: When you've released a new app with a different package name
- Migration: Moving users from an old app to a completely new one
- Duplicate Prevention: Preventing users from having both old and new versions installed
- Clean Migration: Ensuring users uninstall deprecated apps
Common Issues
iOS: "canOpenURL: failed" error
If you see this error, make sure you've added the URL scheme to your Info.plist under LSApplicationQueriesSchemes.
Android: Permission denied
This plugin doesn't require special permissions, but make sure your app targets the correct API level.
Contributing
Contributions are welcome! Please submit pull requests or open issues on GitHub.
License
MIT License
Author
Harrison
Repository
https://github.com/yourusername/cordova-plugin-oldapp-detector
Support
For issues and questions, please open an issue on GitHub.
