Is Expo Pedometer supported on Android? - android

I'm setting up a Pedometer app in React Native using Expo, testing the code on my real Samsung s10 device.
I am using the Expo Pedometer documentation
However, when I use the Pedometer.getStepCountAsync method, I get returned an error "Getting step count for date range is not supported on Android yet."
I am trying to make a pedometer app that reads users steps, and then puts them into some visuals for the user but I can't get the steps data.
My code is below: it reaches the error => line and returns the error mentioned above. :(
I've enabled the Fitness API in my Google Developer Console and am 99% sure I have the right credentials; as I have used the Google Login successfully in the same app.
const end = new Date();
const start = new Date();
start.setDate(end.getDate() - 1);
Pedometer.getStepCountAsync(start, end).then(
result => {
this.setState({ pastStepCount: result.steps });
},
error => {
this.setState({
pastStepCount: "Could not get stepCount: " + error
});
}
);
I guess the expected result is that I get the user's steps from the past day in the result but instead I get the error that it is not supported on android.

I did something nasty as a workaround but it worked I added expo 33 as a legacy npm dependency and use only the pedometer module from there because currently they didn't implemented the pedometer functionality on android on the new Expo unimodules
package.json
"expo": "^35.0.0",
"expo-legacy": "npm:expo#33.0.0",
And use it like this
import {Pedometer} from 'expo-legacy'
Surprisingly compiled and only increased 200kb the apk size

Yes, by using Core Motion (iOS) or Google Fit (Android) to get the user's step count.
Any Android phone running on a 4.4 (KitKat) operating system or later will connect with Google Fit.
Pedometer unable to query steps, documentation unclear/contradictory.

Related

React Native - Mismatch in steps between getDailyStepCountSamples and Google Fit App

Problem
When I call GoogleFit.getDailyStepCountSamples() to retrieve steps, I receive a step count that significantly lower than that shown in the Google Fit app.
Dev Environment
MacOS Big Sur
React Native 0.63.3
Android Simulator - Nexus 5 API 19
Steps to Replicate
Set your step options and call the function. The code would look something like the following
const stepsOpt = {
startDate: '2021-09-15T00:00:00.000Z', // the start of the day in question
endDate: new Date().toISOString(), // you could also set this to the end of the day
bucketUnit: 'MINUTE',
bucketInterval: 1
}
const res = await GoogleFit.getDailyStepCountSamples(stepsOpt)
console.log(`\n\nMy step data is\n${JSON.stringify(res, null, 2)}\n\n`)
In the resulting log, observe data from any com.google.android.gms source. Look at the total steps, and the rawSteps.
Compare this with the total number of steps shown in the Google Fit app for the same day (Can be found by opening the Google Fit app -> Home -> Trends/Steps -> Day -> See source data)
What I Observe
There is a mismatch between both the total steps and the rawSteps
What I Expected
To see a match between the total steps
To see some matches in the rawStep data
Screenshot
On the left is a screenshot of log after running my code. The right is a screenshot of the raw data according to the Google Fit app.
In short, if it's a sync issue, there is nothing you can do about, you just have to wait.
If it's caused by data is only taken from local device storage.
Or parts of data in Google Fit app is from other apps, these two need to be investigated and reproduced.
https://developers.google.com/fit/faq#how_do_i_get_the_same_values_step_count_calories_distance_etc_as_the_google_fit_app

How to run AppsFlyer SDK Integration Test for a Unity project?

I'm working with AppsFlyer in Unity based on the following documentation: https://support.appsflyer.com/hc/en-us/articles/213766183-Unity-plugin-V4-integration-guide-for-developers
I followed the necessary steps but when it came to running the integration test, it just stayed stuck in this screen:
https://imgur.com/a/taXW909
Are there any potential things that I might be missing that could cause this issue? As far as I understand, I need to whitelist my Android device, select it in the SDK Integration Test, scan the QR Code, install my project's .apk file and the AppsFlyer should start detecting something.
Additional details
Here's the script for initializing AppsFlyer:
public class AppsFlyerObject : MonoBehaviour
{
private const string AppsFlyerKey = /* MY DEV KEY */;
private void Start()
{
AppsFlyer.setAppsFlyerKey(AppsFlyerKey);
AppsFlyer.init(AppsFlyerKey, "AppsFlyerTrackerCallbacks");
}
}
Regarding the AppsFlyer app, here're the settings I selected:
https://imgur.com/a/7PxEnlW
I want to test an APK file that is not present on any kind of a store.
Have you tried testing a non-organic install with this link?
https://support.appsflyer.com/hc/en-us/articles/207032126#integration-43-simulating-a-nonorganic-install
If everything implemented correctly, but you are still stuck on this screen - it's very likely you have 'zero plan' on your AppsFlyer account. You cannot pass this test on free plan for some reason.
I've found it after two days by connecting device via logcat and recieving 403 error. You can do same to be sure its your reason too.

Firebase A/B Testing live data not displayed for Android app

The A/B tests for the Android app of my project do not display any live data on the main A/B testing page. Live data is displayed for the iOS version.
I’ve tested the experiments on a couple of Android devices and I’m receiving the correct values from the FirebaseRemoteConfig so the experiments are running correctly.
Here's a screenshot of what I mean
The iOS test is on the left and the Android one is on the right. Although the iOS test was only made 50 minutes ago, it shows data whereas the Android test was created over 20 hours ago and shows no live data.
I understand that "0 Total Users" can be shown for 24 hours or more after the experiment is started so I'm not concerned about that. But since the iOS test shows the live data chart, I find it strange that the Android one doesn't.
The tests are working in devices but I'll add some code as well. Here's how I'm fetching the remote config values.
final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
remoteConfig.setConfigSettings(new FirebaseRemoteConfigSettings.Builder()
.build());
HashMap<String, Object> defaults = new HashMap<>();
defaults.put(PARAMETER_NAME, DEFAULT_VALUE);
remoteConfig.setDefaults(defaults);
long cacheExpirationSeconds = BuildConfig.DEBUG ? 0
: TimeUnit.HOURS.toSeconds(12);
remoteConfig.fetch(cacheExpirationSeconds).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
remoteConfig.activateFetched();
}
});
Any ideas why this is would be helpful, thanks.
Seems this is related to an issue with the latest version of Firebase config SDK. From the release notes:
The latest release of the Firebase Android SDK for Remote Config (v16.1.2) causes A/B Testing to not work as expected. Remote Config SDK v16.1.2 does not collect user behavior for A/B Testing experiments which causes reports to show that an experiment has zero users.
If you've configured both A/B Testing and Remote Config in your project, use v16.1.0 of the Remote Config Android SDK.
I changed to v16.1.0 and it's showing the live data now.
Also, the notes mention the following:
Note that downgrading Remote Config to v16.1.0 requires that the following Android SDKs (if they're used in your project with Remote Config) to be at the following versions:
com.google.firebase:firebase-ads:17.1.1
com.google.firebase:firebase-analytics:16.0.5
com.google.firebase:firebase-dynamic-links:16.1.3
com.google.firebase:firebase-invites:16.0.5
com.google.firebase:firebase-core:16.0.5
I'm only using Firebase core but changing the version to 16.0.5 created conflicts with other Google libraries. I then used the latest version, 16.0.6, and the remote config and live data still work fine. Just for anyone else having some issues with that.

why do I receive multiple FCM notifications on android 7

I am trying to integrate FCM notification in my project. I have Cloud Function backend, and app runs on android.
Below is cloud code to send notification:
exports.notificationTest = functions.database.ref(`/test/childA/childB/status`).onUpdate(event => {
const status = event.data.val();
console.info("Processing notificationTest cloud function")
console.info(`status : ${status}`)
const token = "EnterYourNotificationTokenHere"
const randomNum = Math.floor(Math.random() * 100)
var message = {
notification: { title : "My App", body : `Notification Test ${randomNum}`}
}
console.info(`Sending message on notification token`)
return admin.messaging().sendToDevice(token, message)
.then((response) => {
console.info("Successfully sent notification")
}).catch(function(error) {
console.warn("Error sending notification " , error)
})
})
On native Android app, I receive notification multiple times with interval of few mins.
Here, I have seen notification like this:
Notification Test 30
then after 2,4,8,16,32 mins of previous notification time I again get below message
Notification Test 30
I don't think I need to paste log here, because code is definitely executed just once (as the random number in notification stays the same).
So, why is this happening and how to fix it?
Below is my environment:
Native Android App
Using Android 7
Latest Android Studio Stable
Android Gradle Plugin - 3.1.1
Gradle - 4.1
Firebase-Ui - 3.1.0
Play Services - 11.4.2
Please try to reproduce in environment mentioned above.
I have resolved the issue by renaming my application package name
eg old name: com.xyz to com.xyz2
Using the new name i added this (new) android app to firebase project (it generated new app id). And the notifications started worked as expected (no retry).
But its a shame that I have to rename app package to resolve it. If this app was released in google play then I could not have renamed the app, else no one can get further updates on this app, and it becomes a new app!
It would still be great if some firebase developers could shed light on what is happening.
Recreating firebase project and recreating android project did not help when app name / top level package name were the same. Changing app name and relevant namespaces in existing android project fixed it for now.
Ideally I would like to know the proper fix for this and use the existing name rather than suffixing 2 at the end of app name.
I just had this same issue occur with my Ionic Android app. The same notification repeated after 2, 4, and 8 minutes. This seems to be an issue on the client side because it even happens when sending a message directly from the Firebase console.
I tried several things to fix it and it seems like the only way I could get it to work as intended was to make a new Android project and new Firebase app.

Worklight app results in PERSISTENT_STORE_FAILURE with JSONStore on my phone

I just tried a small sample worklight app on my phone to test the JSONStore, the init code for which is as follows in my file jsontest.js.
function wlCommonInit(){
var i;
var collectionName = 'exp';
var options = {};
var collections = {};
//Object that defines the 'people' collection
collections[collectionName] = {};
//Object that defines the Search Fields for the 'people' collection
WL.JSONStore.destroy(options);
collections[collectionName].searchFields = {name: 'string', age: 'integer'};
WL.JSONStore.init(collections, options)
.then(function () {
alert ("JSON Store initialization success!");
})
.fail(function (errorObject) {
alert (errorObject);
});
I'm getting the error -1: PERSISTENT STORE FAILURE when I run the app on my phone (Galaxy Nexus). The following errorObject is returned.
{
"src": "initCollection",
"err": -1,
"msg": "PERSISTENT_STORE_FAILURE",
"col": "exp"
"usr": "jsonstore",
"doc": {},
"res": {}
}
The app works fine in the Worklight console simulator and in the AVD. My phone has enough storage (600 MB left) to run the app so that shouldn't be a problem.
What am I doing wrong here? Does this have anything to do with the fact that I'm running a custom ROM?
UPDATE: I checked the app on my dad's phone (Sony Xperia Sola) and it worked! Very weird. It doesn't run on my phone, even though all other third-party apps that I have downloaded so far on my phone from the Play Store and other sources all work fine.
So, does Worklight not support custom ROMs?
The custom ROM that I am using is VanirAOSP. I applied a popular custom kernel and I'm using the Dalvik runtime (not ART or anything like that).
I also think that the problem might be because Worklight apps are not fully supported on Android 4.4 KitKat.
Would appreciate it if someone would shed some light on this.
There is an issue that affects the JSONstore when using Worklight 6.0 on Android 4.4, which causes the behavior your are seeing. You can get more information about this here:
http://www-01.ibm.com/support/docview.wss?uid=swg27040512
If you are using Worklight Consumer Edition or Worklight Enterprise Edition, you can get a fix for this issue by upgrading to Worklight 6.0.0.2 (a/k/a Worklight 6.0 Fix Pack 2).
If you are using Worklight Developer Edition, you should be able to use the Eclipse "Check for Updates" function to upgrade your Worklight 6.0 Developer Edition installation to Fix Pack 2.
Note that after applying the fix, you must remove the JSONstore feature from your application, and then add it back again; this is described in the APAR document that you can access from the page I've linked above.

Categories

Resources