Skip to content

Commit

Permalink
fix(app): use alternative to deprecated versionCode (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jun 22, 2021
1 parent fb8dbb8 commit 6ebabf7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Build;
import androidx.activity.OnBackPressedCallback;
import com.getcapacitor.JSObject;
import com.getcapacitor.Logger;
Expand Down Expand Up @@ -80,7 +81,11 @@ public void getInfo(PluginCall call) {
String appName = stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : getContext().getString(stringId);
data.put("name", appName);
data.put("id", pinfo.packageName);
data.put("build", Integer.toString(pinfo.versionCode));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
data.put("build", Long.toString(pinfo.getLongVersionCode()));
} else {
data.put("build", Integer.toString(pinfo.versionCode));
}
data.put("version", pinfo.versionName);
call.resolve(data);
} catch (Exception ex) {
Expand Down

0 comments on commit 6ebabf7

Please sign in to comment.