How can I get the application version? (Android)
frida -U -f it.subito -l '/path/to/get-app-version.js'
output: 6.39.4
I bumped into a Frida issue that solved my problem.
get-app-version.js
Java.perform(() => {
const ActivityThread = Java.use('android.app.ActivityThread')
const currentApplication = ActivityThread.currentApplication()
const context = currentApplication.getApplicationContext()
const pkgManager = context.getPackageManager()
const pkgInfo = pkgManager.getPackageInfo(context.getPackageName(), 128)
/* Don't work */
// console.log('version: ', pkgInfo.versionName)
// console.log('version: ', pkgInfo._versionName.value)
console.log('version: ', pkgInfo.getClass().getField('versionName').get(pkgInfo))
})
First console.log prints:
version: [object Object]
Second one throws an error:
TypeError: cannot read property 'value' of undefined
at <anonymous> (/frida/repl-2.js:23)
at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:12)
at _performPendingVmOps (frida/node_modules/frida-java-bridge/index.js:250)
at <anonymous> (frida/node_modules/frida-java-bridge/index.js:225)
at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:12)
at _performPendingVmOpsWhenReady (frida/node_modules/frida-java-bridge/index.js:244)
at perform (frida/node_modules/frida-java-bridge/index.js:204)
at <anonymous> (/frida/repl-2.js:26)
Third one works like a charm.
Unluckily I don't know why the short version pkgInfo.versionName doesn't work.
Related
I'm using react-native (not expo), the react-native version is 0.64.2
The reanimated version is 2.2.3
Having some problems with reanimated2 interpolateNode.
Here is the snack reproducing the problem
https://snack.expo.dev/#vladid/juicy-raspberries
Here is the code:
function AnimatedSomething(){
const inputRange = [0, 1];
const outputRange = [1, 0.4];
const sharedPosition = useSharedValue(1);
const opacityStyle = useAnimatedStyle(() => {
const opacity = interpolateNode(
sharedPosition.value,
inputRange,
outputRange
);
return {
opacity
}
})
What am I missing? Thank you in advance.
Maybe my previous answer from : https://stackoverflow.com/a/71873715/12637199 might help you.
If not, try removing the reanimated version and use native animation from react-native which is working perfectly fine.
And you are adding a useless value in your interpolate:
const sharePosition = new Animated.Value(1);
const animatedOpacity = sharePosition.interpolate({inputRange, outputRange});
I am getting this error whenever I try to execute the TextToSpeech.speak() function from #capacitor-community/text-to-speech#0.2.3:
Uncaught (in promise) Error: Not supported on this device.
at n.value (29.a169ec33.chunk.js:formatted:3022)
at n.<anonymous> (29.a169ec33.chunk.js:formatted:2842)
at c (26.902cd79a.chunk.js:2)
at Generator._invoke (26.902cd79a.chunk.js:2)
at Generator.next (26.902cd79a.chunk.js:2)
at 29.a169ec33.chunk.js:formatted:2816
at new Promise (<anonymous>)
at l (29.a169ec33.chunk.js:formatted:2793)
at n.value (29.a169ec33.chunk.js:formatted:2836)
at 29.a169ec33.chunk.js:formatted:4997
Here is my code below:
import { TextToSpeech } from '#capacitor-community/text-to-speech';
const androidSpeak = async () => {
await TextToSpeech.speak({
text: 'This is a sample text.',
locale: 'en_US',
pitchRate: 1.0,
speechRate: 1.0,
volume: 1.0,
category: 'ambient',
});
};
Whenever I trigger the function it gives me the error above. Anyone experienced it before?
Modules:
#capacitor/android: ^2.4.2
#capacitor-community/text-to-speech: ^0.2.3
https://github.com/capacitor-community/text-to-speech
Change the language from 'en_US' to 'en' and it will work.
After Researching for last 24 hour i have found a very effective way to verify in app purchase but didn't get proper Information . I am looking to verify product purchase .
I tried to deploy the js file to firebase cloud function but showing i have error in exports.validatePurchases = functions.database method . Can anyone please have a look on it and fix the error ?
Here is the code :
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const {google} = require("googleapis");
const publisher = google.androidpublisher('v2');
const authClient = new google.auth.JWT({
email: '',
key: '',
scopes: ['https://www.googleapis.com/auth/androidpublisher']
});
admin.initializeApp();
exports.validatePurchases = functions.database
.ref('/purchases/{uId}/{orderId}')
.onCreate((event, context) => {
const purchase = event.val();
if (purchase.is_processed === true) {
console.log('Purchase already processed!, exiting');
return null;
}
const orderId = context.params.orderId;
const dbRoot = event.ref.root;
const package_name = purchase.package_name;
const sku = purchase.sku;
const my_token = purchase.token;
authClient.authorize((err, result) => {
if (err) {
console.log(err);
}
publisher.purchases.products.get({
auth: authClient,
packageName: package_name,
productId: sku,
token: my_token
}, (err, response) => {
if (err) {
console.log(err);
}
// Result Status must be equals to 200 so that the purchase is valid
if (response.status === 200) {
return event.ref.child('is_validated').set(true);
} else {
return event.ref.child('is_validated').set(false);
}
});
});
return null;
});
The Error i have got while deploy :
Functions deploy had errors with the following functions:
validatePurchases
To try redeploying those functions, run:
firebase deploy --only functions:validatePurchases
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
In Firebase Function Log :
Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'googleapis'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/srv/index.js:3:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
First, run cmd on Function Folder of your project :
Then, In order to add it as a dependency, run the following command:
$ npm install googleapis
Now Check if any functions are live on your project. If there are functions in the firebase console remove it. Now Try Deploy.
I'm trying to follow along with expo's in app purchases documentation.. I have the android developer account and set up my in-app-purchase on that account for the same app. I'm just trying to get started with the documentation and receive an error immediately.
If you look at the documentation, I'm just trying to enter in what's in the first example. I call this function at the beginning of the render method of my app.
import * as InAppPurchases from 'expo-in-app-purchases';
...
const getHistory = async function(){
const history = await connectAsync();
if (history.responseCode === IAPResponseCode.OK) {
history.results.forEach(result => {
console.log(result)
});
}
}
And I receive these errors
[Unhandled promise rejection: ReferenceError: Can't find variable: connectAsync]
* App.js:57:19 in getHistory
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:271:30 in invoke
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:28 in invoke
- node_modules/regenerator-runtime/runtime.js:170:17 in Promise$argument_0
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
...
You need to import in-app purchases module first. Like this:
import * as InAppPurchases from 'expo-in-app-purchases';
const getHistory = async function(){
const history = await InAppPurchases.connectAsync();
if (history.responseCode === IAPResponseCode.OK) {
history.results.forEach(result => {
console.log(result)
});
}
}
Also, note this from the documentation you linked:
You must ensure that you have installed and configured the react-native-unimodules package before continuing.
and this:
Note that in-app purchases require physical devices to work on both platforms and therefore cannot be tested on simulators.
Since you used:
import * as InAppPurchases from 'expo-in-app-purchases';
That means your code should look like:
...
const getHistory = async function(){
const history = await InAppPurchases.connectAsync();
if (history.responseCode === InAppPurchases.IAPResponseCode.OK) {
history.results.forEach(result => {
console.log(result)
});
}
}
I'm trying to test a very simple nodeJS function that monitors if a new document added to a collection (Notifications) then assign the super document id (userID) of that document and the child document id (notificationID) and print them to the console.
'use-strict'
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.firestore.document('Users/{userID}/Notifications/{notificationID}').onWrite(event => {
const to_user = event.params.userID;
const notification_id = event.params.notificationID;
console.log("Notification ID: " + notification_id + " Sent to: " + to_user );
});
And this is the output at Firebase Functions:
TypeError: Cannot read property 'userID' of undefined
at exports.sendNotification.functions.firestore.document.onWrite.event (/user_code/index.js:8:33)
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
at next (native)
at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
at /var/tmp/worker/worker.js:700:26
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
You're using the new 1.0 SDK, but writing code for the old versions. The first parameter to the callback passed to onWrite() is now a Change object. The second parameter (which you're not using here) is now an EventContext object that has a params property which has the userID wildcard value you're looking for.