I want to give force update feature in my app for android users - ionic-framework

I am using ionic 3 for these and i need to give a force update feature for android users.
can i able to do it with-->
like first compare current play store version and user version and then set
a page for those users who don't have the updated version and force user's
for update the app, can i use file transfer plugin for update the app.
what approch is right?

You can use following plugins to verify that updates is available in playstore.
cordova-plugin-app-update
You should first host an XML file on your server with the following data in it:
<update>
<version>302048</version>
<name>APK Name</name>
<url>https://your-remote-api.com/YourApp.apk</url>
</update>
And then check with
constructor(private appUpdate: AppUpdate) {
const updateUrl = 'https://your-remote-api.com/update.xml';
this.appUpdate.checkAppUpdate(updateUrl).then(() => { console.log('Update
available') });
}
More details available here

Did you try this with release build package ?

Related

How can we implement in app update in flutter app

I want to implement in-app-update or on-the-air update which means whenever the user opens the app, it checks and automatically downloads a new chunk of code and merges it, and asks the user to restart like most of the games (COD, PUBGm) do.
NOTE : I'm not talking about in_app_update
I tried to find out the basic workflow but could not.
I am assuming that what you need is what Firebase Remote config does, you can read about it and get more details from its Flutterfire docs

Is there a way to get the previous version of an app or know if it has been updated or downloaded?

I was trying to build a feature announcement where I can tell the users that there is a new feature available on my flutter app.
The problem is that I don’t want to show this if someone just downloaded the app, since they are new users anyway, I just want to show that to users that were using the app before.
Is there a way to know previous versions of the app that were installed or if the app was updated vs just downloaded?
First of All there is package to find your app current version number and build number, I have used this personally with the backend to show some new features to our new users.
Add this to your package's pubspec.yaml file:
package_info: ^0.4.0+16
Now import the statement into your dart file
import 'package:package_info/package_info.dart';
And use this if your method is marked as async:
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String appName = packageInfo.appName;
String packageName = packageInfo.packageName;
String version = packageInfo.version;
String buildNumber = packageInfo.buildNumber;
Now, What you have to do is that send the current version number in your API,
And have a Current Version Value stored in backend, To check for the Versions you are sending in the API's and Compare them to show new Features,
Like Say If I am old User, So My APP Version number is 1 and API's is sending 1 in the backend too.
But If I am new User then, My APP version is number greater than 1 and API's is sending version number greater than 1, And I can see the update in the app if My Version number is greater than 1 as a new User.
Click Here For More Reference to use the Package
Sorry For bad English

how to show showBusyIndicator into xdk html5 hybrid application?

i added the cordova-notification plugin into intel-xdk appication, when try to show the indicator i get this error:
Uncaught TypeError: Cannot read property 'showBusyIndicator' of undefined
this is the code:
$(document).on("change","#sel_produttori", function(evt)
{
intel.xdk.notification.showBusyIndicator();
});
maybe it is strange the plugin is listed in the first window but not in the second one.
Many of the 'intel.xdk' plugins have been or are being deprecated in favor of their standard core Cordova counterparts. I would recommend using that instead.
The problem you're running into appears to be that you've included the standard Cordova notification plugin, but you're trying to access the intel.xdk notification plugin, which is not included and therefore doesn't exist in your app.
It looks like the corresponding method on the standard Cordova Notification plugin was deprecated some time back and isn't there anymore. You might want to try a plugin like this:
https://github.com/filfat-Studios-AB/cordova-plugin-spinnerdialog
It seems to work for me but, as always, use at your own risk.

Delete Apk after app installation

I am working on an app in which I have to restrict the user to share the apk personally. One can download it but should not be allowed to share the App (apk) personally via bluetooth etc.
I searched and read alot about the same issue but didn't find a complete answer. I have tried the below.
How to get the file *.apk location in Android device
Download, Installing and Delete .apk file on android device programmatically from a website other than marketplace
What I have understood from above is that the easy way to do this is to delete the apk file from the User's device after the app is installed. (I also know that user may generate this apk again via root access but that is fine as at-least I will be able to restrict not all but many).
Now what I have tried, I am registering a Broadcast receiver and in my onReceive() method I have the below,
PackageManager pm = getPackageManager();
for (ApplicationInfo app : pm.getInstalledApplications(0)) {
if (myPackage.equalsIgnoreCase(app.packageName)) {
apkPath = app.sourceDir;
break;
}
}
Log.d("Package", myPackage + " - APK - " + apkPath);
if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard, apkPath);
file.delete();
}
But this does nothing as I am not aware of the IntentFilter I should use to register this.
Can any one guide me on what is the next step? and in case I am completely on a wrong land then help me achieve the above?
Any help will be appreciated. :)
On later versions of Android, some (all?) broadcasts aren't sent to an app until it has been manually opened at least once. This is a security feature that can't be circumvented.
As far as I know, It is not possible to listen the installation complete broadcast event. Android Api having Broadcast Action: "ACTION_PACKAGE_ADDED" But newly installed package does not receive this broadcast. Source : Here
My suggestion is check in your first launcher activity and delete the apk.
You can use the Android App Licensing Service here.
Refer http://developer.android.com/google/play/licensing/index.html and the implmentation here http://developer.android.com/google/play/licensing/adding-licensing.html.
This will ensure that the apk cannot be shared(making it protected) using any of the apps available on market.
Sorry for bad english.
Here my solution not actual code:
1) set your broadcastreciver when any new application is install in your device.
2) When your broadcastreciver is call, that time you write code in onRecive() method
check the your app package if install or not
private boolean isPackageInstalled(String packagename, Context context) {
PackageManager pm = context.getPackageManager();
try {
pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
using this method or any
if you get true means your application is install
3) if you get true from isPackageInstalled("com.download.app", context) method
that time delete apk file from your SD card or any loaction in device
if you more clarification i will be explain.
i used the idea of creating a folder when the app runs for the first time .if it doesnot exist , delete the apk. if the folder exists , then the apk has already been deleted.
This folder will be deleted on its own if the app is unstalled.
public static String link = Environment.getExternalStorageDirectory()
.getPath() + "/Android/data/YourAppPackageName/";
//check if its running for the first time
File f = new File(link);
if (f.exists()) {
File f1 = new File("/data/app/YourAppPackageName.apk")
if(f1.exists()){f1.delete();}
}
else {
f.mkdirs();
}
You can also use the HockeyApp product and distribute using the Android App that they provide, as well as enable the "restriction" features. I'm pretty sure that will do what you need without having to write extra code.

How to cause a chrome app to update as soon as possible?

Deploying a chrome packaged app and publishing updates on the chrome web store allows users to automatically receive application updates. There are situations where you want to know if the running application is the most current or not, and updating it. E.G.:
Just keeping the user on the most recent version.
Detecting a mismatch between the application and server side APIs, and requiring the client side application to update to use new server side APIs.
Documentation for chrome.runtime.requestUpdateCheck() offers a status of "throttled", "no_update", "update_available", but doesn't indicate what to do if a newer version is required.
Install a listener for chrome.runtime.onUpdateAvailable, which fires when the new .crx file has been downloaded and the new version is ready to be installed. Then, call chrome.runtime.requestUpdateCheck:
chrome.runtime.onUpdateAvailable.addListener(function(details) {
console.log("updating to version " + details.version);
chrome.runtime.reload();
});
chrome.runtime.requestUpdateCheck(function(status) {
if (status == "update_available") {
console.log("update pending...");
} else if (status == "no_update") {
console.log("no update found");
} else if (status == "throttled") {
console.log("Oops, I'm asking too frequently - I need to back off.");
}
});
Depending on your application, when an update is detected you may want to use something like setTimeout and call chrome.runtime.restart() or chrome.runtime.restart() later
According to the Google Chrome documentation you need to have
chrome.runtime.onUpdateAvailable.addListener(function(details) {
chrome.runtime.reload(); // To restart the chrome App instantaneously
});
But this take time to reflect JS changes into the chrome because background.js loaded into the background and it needs to be unloaded and loaded again
To cop this situation you need to include
chrome.runtime.onInstalled.addListener(function(details) {
chrome.runtime.reload();
});
as wel.
onInstalled called whenever google extension installed first time (fresh installation), google extension updated or google chrome updated.