Please provide the following:
- SDK Version: 43
- Platforms(Android/iOS/web/all): iOS
I create a simple project to test, it works on Android, but not working on iOS (both of debug mode and release mode)
package.json:
{
"name": "testfbtwo",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "~43.0.2",
"expo-facebook": "~12.0.3",
"expo-status-bar": "~1.1.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-web": "0.17.1"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
Here is my step:
- expo init testfbtwo
- expo install expo-facebook
- edit app.json
- set bundle id
com.testfbtwo.app
on Facebook dashboard - run the project, then click r
equestPermissionsAsync first
and clickThen Log an event
after a few seconds
I set facebookSchemeăfacebookAppIdăfacebookDisplayNameăfacebookAutoLogAppEventsEnabledăfacebookAdvertiserIDCollectionEnabled on app.json, also I set NSUserTrackingUsageDescription even Iâm not sure it is necessary or not on event tracking
{
"expo": {
"name": "testfbtwo",
"slug": "testfbtwo",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.testfbtwo.app",
"buildNumber": "14",
"infoPlist": {
"NSUserTrackingUsageDescription": "need permissions"
}
},
"android": {
"package": "com.testfbtwo.app",
"versionCode": 1,
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
}
},
"web": {
"favicon": "./assets/favicon.png"
},
"facebookScheme": "fb1035322220370359",
"facebookAppId": "1035322220370359",
"facebookDisplayName": "testfbtwo",
"facebookAutoLogAppEventsEnabled": true,
"facebookAdvertiserIDCollectionEnabled": true
}
}
Here is my App.js
import {StatusBar} from 'expo-status-bar';
import React, {useEffect} from 'react';
import {StyleSheet, Text, View, TouchableOpacity, Platform} from 'react-native';
import * as Facebook from 'expo-facebook';
export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<TouchableOpacity
onPress={() => {
Facebook.getPermissionsAsync().then(async (v) =>
console.log('permissions v', v)
);
}}
>
<Text style={{fontSize: 20}}>getPermissionsAsync</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={async () => {
alert('Initial');
await Facebook.initializeAsync({
appId: '1035322220370359',
// version: Platform.select({web: 'v5.0'}),
});
if (Platform.OS === 'ios') {
Facebook.requestPermissionsAsync().then(async (v) => {
console.log('requestPermissionsAsync', v);
const {status} = v;
if (status === 'granted') {
await Facebook.setAdvertiserTrackingEnabledAsync(true);
await Facebook.setAutoLogAppEventsEnabledAsync(true);
await Facebook.setAdvertiserIDCollectionEnabledAsync(true);
}
});
}
}}
>
<Text style={{fontSize: 20}}>requestPermissionsAsync first</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={async () => {
alert('Send Event');
if (Platform.OS === 'ios') {
await Facebook.logEventAsync('testIOS');
} else {
await Facebook.logEventAsync('testAndroid');
}
}}
>
<Text style={{fontSize: 20}}>Then Log an event</Text>
</TouchableOpacity>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Why event doesnât display on Facebook dashboard on iOS ?
Is the expo-facebook issue ? Or I did something wrong ?
Any help would be appreciated. Thanks.