I’ve drawback my app by no means will get an opportunity to fetch the requests, i believed perhaps IOS wants time to initialize that so i attempted on three actual units and waited three days utilizing construct from Testflight, however by no means obtained it … When it will get fetch probability it ought to fetch my backend to provide like a faux request (i made this for me to verify its working), nevertheless it by no means fetches it however when i attempt to do it manually Xcode > Debug > Simulate Background fetch
it really works wonderful.
here is my App.tsx
import { SafeAreaProvider } from "react-native-safe-area-context";
import React, { useEffect } from "react";
import { Supplier, useSelector } from "react-redux";
import { StateInterface, retailer } from "./mredux";
import Format from "./components/Format";
import {
NativeAppEventEmitter,
NativeEventEmitter,
NativeModules,
} from "react-native";
import { Auth0Provider, useAuth0 } from "react-native-auth0";
import AppleHealthKit, {
HealthKitPermissions,
HealthObserver,
} from "react-native-health";
import { getHealthData, permissionsHealth } from "./utils/permissions";
import * as TaskManager from "expo-task-manager";
import * as BackgroundFetch from "expo-background-fetch";
import axios from "axios";
import { getItem } from "./utils/asyncstorage";
import * as Gadget from "expo-device";
import { updateMainState } from "./utils/updatestate";
import { pushHealthData, requestFetchProcess } from "./utils/api.service";
const BACKGROUND_FETCH_TASK = "com.transistorsoft.well being";
TaskManager.defineTask(BACKGROUND_FETCH_TASK, async ({ error }) => {
if (error) {
console.log("Background fetch error:", error);
return BackgroundFetch.BackgroundFetchResult.Failed;
}
console.log("Background fetch activity began at", new Date().toISOString());
attempt {
// THIS FAKE REQUEST I WAS TALKING ABOUT
requestFetchProcess()
.then(() => console.log("DONE!"))
.catch(console.log);
fetchHealthData()
.then(() => console.log("DONE!"))
.catch(console.log);
console.log(
"Background fetch activity accomplished efficiently at",
new Date().toISOString()
);
return BackgroundFetch.BackgroundFetchResult.NewData;
} catch (error) {
console.log("Background fetch activity error:", error);
return BackgroundFetch.BackgroundFetchResult.Failed;
}
});
export const registerBackgroundFetchAsync = async () => {
attempt {
const standing = await BackgroundFetch.getStatusAsync();
console.log("Background fetch standing:", standing);
console.log(
"Background fetch standing:",
BackgroundFetch.BackgroundFetchStatus.Accessible
);
if (
standing === BackgroundFetch.BackgroundFetchStatus.Restricted ||
standing === BackgroundFetch.BackgroundFetchStatus.Denied
) {
console.log("Background fetch is just not enabled.");
return;
}
await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
minimumInterval: 15 * 60, // Fetch information each 15 minutes
stopOnTerminate: false,
startOnBoot: true,
});
console.log("Background fetch activity registered efficiently.");
} catch (error) {
console.log("Error registering background fetch activity:", error);
}
};
const fetchHealthData = async () => {
attempt {
const healthData = await getHealthData(new Date());
const deviceInfo = retailer.getState().mainReducer.deviceInfo;
const req = await pushHealthData(healthData, deviceInfo, true);
console.log("Server response:", req);
} catch (error) {
console.log("Error fetching well being information:", error);
}
};
export default perform App() {
useEffect(() => {
updateMainState({
deviceInfo: {
deviceType: Gadget.deviceType as unknown as string,
producer: Gadget.producer,
modelName: Gadget.modelName,
osName: Gadget.osName,
},
});
registerBackgroundFetchAsync();
}, []);
return (
<SafeAreaProvider>
<Supplier retailer={retailer}>
<Format />
</Supplier>
</SafeAreaProvider>
);
}
Additionally i already added activity identify into BGTaskSchedulerPermittedIdentifiers
in information.plist here is my config:
n<?xml model="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="1.0">
<dict>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.transistorsoft.fetch</string>
<string>com.transistorsoft.well being</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>lexy Join</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>com.lexyhealth.join</string>
<string>com.lexyhealth.join</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.lexyhealth.join.auth0</string>
</array>
</dict>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>exp+lexy-connect</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>NSFaceIDUsageDescription</key>
<string>Enable $(PRODUCT_NAME) to entry your Face ID biometric information.</string>
<key>NSHealthClinicalHealthRecordsShareUsageDescription</key>
<string>Learn and perceive scientific well being information.</string>
<key>NSHealthShareUsageDescription</key>
<string>Learn and perceive well being information.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>Share exercise information with different apps.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Enable $(PRODUCT_NAME) to entry your location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Enable $(PRODUCT_NAME) to entry your location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Enable $(PRODUCT_NAME) to entry your location</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>fetch</string>
<string>location</string>
<string>processing</string>
</array>
<key>UILaunchStoryboardName</key>
<string>SplashScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UIRequiresFullScreen</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIUserInterfaceStyle</key>
<string>Gentle</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
package deal.json
...
"expo": "^51.0.8",
"expo-background-fetch": "~12.0.1",
"expo-task-manager": "~11.8.1",
...
I hope i can discover a resolution for this, when you’ve got one other resolution i can do as a substitute of expo one it’s going to be grateful
thanks guys
I attempted all different packages and like every little thing, and nothing!