dependencies:
traffic_router:
git:
url: https://github.com/MrOlolo/traffic_router
On the Firebase Console, add a new Android app or select an existing Android app for your Firebase project.
The "Android package name" must match your local project's package name that was created when you
started the Flutter project. The current package name can be found in your module (app-level) Gradle
file, usually android/app/build.gradle
, defaultConfig
section (example package name:
com.yourcompany.yourproject
).
Once your Android app has been registered, download the configuration file from the Firebase
Console (the file is called google-services.json
). Add this file into the android/app
directory
within your Flutter project.
To allow Firebase to use the configuration on Android, the 'google-services' plugin must be applied
on the project. This requires modification to two files in the android/
directory.
First, add the 'google-services' plugin as a dependency inside of the android/build.gradle
file:
buildscript {
dependencies {
// ... other dependencies
classpath 'com.google.gms:google-services:4.3.8'
}
}
Lastly, execute the plugin by adding the following underneath the line apply plugin: ' com.android.application'
, within the /android/app/build.gradle
file:
apply plugin: 'com.google.gms.google-services'
For Android configuration, you can follow the same instructions of the Flutter Facebook App Events plugin: Read through the "Getting Started with Facebook SDK for Android" tutorial and in particular,
- Add the following to your strings.xml file
<string name="facebook_app_id">[APP_ID]</string>
<string name="facebook_client_token">[CLIENT_TOKEN]</string>
- Add the following
meta-data
to theapplication
element in AndroidManifest.xml
<application android:label="@string/app_name" ...>
...
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/><meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
...
</application>
Add this permissions to your AndroidManifest.xml
file:
<uses-permission android:name="android.permission.INTERNET" />
<!-- For sim info-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Fix WebView error at some Samsung devices-->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Apps with target API level set to 31 (Android 12) or later must declare-->
<!-- the normal permission com.google.android.gms.AD_ID as below-->
<!-- in order to use this API.-->
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
If you use http
links add to <application>
at your AndroidManifest.xml
file:
<application android:usesCleartextTraffic="true">
. . .
</application>
On the Firebase Console, add a new iOS app
or select an existing iOS app for your Firebase project. The "iOS bundle ID" must match your local
project bundle ID. The bundle ID can be found within the "General" tab when
opening ios/Runner.xcworkspace
with Xcode.
Download the GoogleService-Info.plist
file for the Firebase app.
Next you must add the file to the project using Xcode (adding manually via the filesystem won't link
the file to the project). Using Xcode, open the project's ios/{projectName}.xcworkspace
file.
Right click Runner from the left-hand side project navigation within Xcode and select "Add files".
Select the GoogleService-Info.plist
file you downloaded, and ensure the "Copy items if needed"
checkbox is enabled
Add any URL schemes passed to canLaunch
as LSApplicationQueriesSchemes
entries in your
Info.plist file.
Example:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
</array>
For iOS configuration, you can follow the same instructions of the Flutter Facebook App Events
plugin:
Read through
the "Getting Started with App Events for iOS"
tutorial and in particular,
follow step 4
by opening info.plist
"As Source Code" and add the following
- If your code does not have
CFBundleURLTypes
, add the following just before the final</dict>
element:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb[APP_ID]</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookClientToken</key>
<string>[CLIENT_TOKEN]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>
<key>FacebookAutoLogAppEventsEnabled</key>
<true/>
<key>FacebookAdvertiserIDCollectionEnabled</key>
<false/>
void routerInit(NavigatorState navigator) async {
/// To initialize trafficRouter instance
/// Also you can set [Settings] param at [initialize]
final trafficRouter = await TrafficRouter.initialize(
settings: Settings(paramNames: ParamNames(...)));
///U can navigate with default route function or create ur own
trafficRouter.routeWithNavigator(
navigator,
(context) => const MyHomePage(title: 'App'),
(url) =>
WebViewPage(url: url
)
,
);
}
Update version ext.kotlin_version
to 1.5.31
at android\build.gradle