这通常是由于使用未经授权的API密钥引起的。为避免此错误,请确保您的API密钥已经授权并且已正确设置。您可以遵循以下步骤来解决此问题。
例子:
import io.invertase.firebase.app.ReactNativeFirebaseAppPackage;
import io.invertase.firebase.messaging.ReactNativeFirebaseMessagingPackage;
import io.invertase.firebase.notifications.ReactNativeFirebaseNotificationsPackage;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
public class PowerIIApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("APP_ID")
.setApiKey("API_KEY")
.build();
FirebaseApp.initializeApp(context, options, "secondary");
// ...
}
}
请注意:您需要将“APP_ID”和“API_KEY”替换为您在Firebase控制台中设置的应用程序ID和API密钥。
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
export default class MyComponent extends React.Component {
render() {
return(
{
// 'details' is provided when fetchDetails = true
console.log(data, details);
}}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'GOOGLE_MAPS_API_KEY',
language: 'en', // language of the results
}}
styles={{
textInputContainer: {
width: '100%',
},
description: {
fontWeight: 'bold',
},
predefinedPlacesDescription: {
color: '#1faadb',
},
}}
currentLocation={true}
currentLocationLabel="Current location"
nearbyPlacesAPI='GooglePlacesSearch'
GoogleReverseGeocodingQuery={{}}
GooglePlacesSearchQuery={{
rankby: 'distance',
types: 'food',
}}
predefinedPlaces={[...]}
/>
);
}
}
请注意:您需要将“GOOGLE_MAPS_API_KEY”替换为您在Google控制台中设置的API密钥。