安卓原生集成
1.注册应用
2.下载配置文件
3.添加 Firebase SDK
项目级 build.gradle(<项目>/build.gradle
):
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}
应用级 build.gradle(<项目>/<应用模块>/build.gradle
):
apply plugin: 'com.android.application'
// Add this line
apply plugin: 'com.google.gms.google-services'
dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:29.0.4')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
}
4.例子仓库
IOS原生集成
1.注册应用
2.下载配置文件
3.添加 Firebase SDK
4.添加初始化代码
要在您的应用启动时连接 Firebase,请将下面的初始化代码添加到您的主 AppDelegate
类。
@import UIKit;
@import Firebase;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure]
return YES;
}