我尝试使用 FCM 的原生脚本firebase 插件,以便在我的原生中实施推送通知脚本应用。但是当我根据文档调用firebase init尝试启动firebase时。
firebase.init({
onMessageReceivedCallback: function(message) {
console.log("Title: " + message.title);
console.log("Body: " + message.body);
// if your server passed a custom property called 'foo', then do this:
console.log("Value of 'foo': " + message.data.foo);
}
}).then(function (instance) {
console.log("firebase.init done");
}, function (error) {
console.log("firebase.init error: " + error);
});
我收到此错误
Error in firebase.init: Error: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:275)
com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:231)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
com.tns.Runtime.callJSMethod(Runtime.java:957)
com.tns.Runtime.callJSMethod(Runtime.java:941)
com.tns.Runtime.callJSMethod(Runtime.java:933)
com.tns.gen.android.view.GestureDetector_SimpleOnGestureListener_frnal_ts_helpers_l58_c38__TapAndDoubleTapGestureListenerImpl.onSingleTapUp(GestureDetector_SimpleOnGestureListener_frnal_ts_helpers_l58_c38__TapAndDoubleTapGestureListenerImpl.java:12)
android.view.GestureDetector.onTouchEvent(GestureDetector.java:635)
android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480)
android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
com.tns.Runtime.callJSMethod(Runtime.java:957)
com.tns.Runtime.callJSMethod(Runtime.java:941)
com.tns.Runtime.callJSMethod(Runtime.java:933)
但在插件安装期间,我只对云消息和 Android平台设置为yes。我没有使用firebase身份验证。对于Facebook登录,我使用 native-script-OAuth 插件。
来自 nativescript-plugin-firebase / platform / android
的 include.gradleandroid {
productFlavors {
"fireb" {
dimension "fireb"
}
}
}
repositories {
jcenter()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
def supportVersion = project.hasProperty("supportVersion") ? project.supportVersion : "26.0.0"
dependencies {
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:cardview-v7:$supportVersion"
compile "com.android.support:customtabs:$supportVersion"
compile "com.android.support:design:$supportVersion"
compile "com.android.support:support-compat:$supportVersion"
def firebaseVersion = "12.0.1"
// make sure you have these versions by updating your local Android SDK's (Android Support repo and Google repo)
compile "com.google.firebase:firebase-core:$firebaseVersion"
compile "com.google.firebase:firebase-auth:$firebaseVersion"
// for reading google-services.json and configuration
def googlePlayServicesVersion =
project.hasProperty('googlePlayServicesVersion') ?
project.googlePlayServicesVersion : firebaseVersion
compile "com.google.android.gms:play-services-
base:$googlePlayServicesVersion"
// Uncomment if you want to use the regular Database
// compile "com.google.firebase:firebase-database:$firebaseVersion"
// Uncomment if you want to use 'Cloud Firestore'
// compile "com.google.firebase:firebase-firestore:$firebaseVersion"
// Uncomment if you want to use 'Remote Config'
// compile "com.google.firebase:firebase-config:$firebaseVersion"
// Uncomment if you want to use 'Crash Reporting'
// compile "com.google.firebase:firebase-crash:$firebaseVersion"
// Uncomment if you want FCM (Firebase Cloud Messaging)
compile "com.google.firebase:firebase-messaging:$firebaseVersion"
// Uncomment if you want Google Cloud Storage
// compile "com.google.firebase:firebase-storage:$firebaseVersion"
// Uncomment if you want AdMob
// compile "com.google.firebase:firebase-ads:$firebaseVersion"
// Uncomment if you need Facebook Authentication
// compile ("com.facebook.android:facebook-android-sdk:4.+"){ exclude group: 'com.google.zxing' }
// Uncomment if you need Google Sign-In Authentication
// compile "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
// Uncomment if you need Firebase Invites or Dynamic Links
// compile "com.google.firebase:firebase-invites:$firebaseVersion"
}
apply plugin: "com.google.gms.google-services"
如果有人帮助我,那就太好了。
答案 0 :(得分:1)