Skip to content

Commit

Permalink
fix(app): get correct build value (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Mar 10, 2022
1 parent 2493c7a commit 4d3b125
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.net.Uri;
import android.os.Build;
import androidx.activity.OnBackPressedCallback;
import androidx.core.content.pm.PackageInfoCompat;
import com.getcapacitor.JSObject;
import com.getcapacitor.Logger;
import com.getcapacitor.Plugin;
Expand Down Expand Up @@ -75,11 +76,7 @@ public void getInfo(PluginCall call) {
String appName = stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : getContext().getString(stringId);
data.put("name", appName);
data.put("id", pinfo.packageName);
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("build", Integer.toString((int) PackageInfoCompat.getLongVersionCode(pinfo)));
data.put("version", pinfo.versionName);
call.resolve(data);
} catch (Exception ex) {
Expand Down

0 comments on commit 4d3b125

Please sign in to comment.