I get Unresolved reference: setPluginRegistrant error when I try to add the below code in the Application.kt file:
Code causing the issue:
FlutterFirebaseMessagingBackgroundService.setPluginRegistrant(this);
My Application.kt file:
package com.application.test
import io.flutter.app.FlutterApplication
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService;
class Application : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingBackgroundService.setPluginRegistrant(this); //this line is the issue
}
override fun registerWith(registry: PluginRegistry?) {
GeneratedPluginRegistrant.registerWith(FlutterEngine(this));
}
}
Without this line, the code compiles but I get the following leak via LeakCanary:
io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService instance
​ Leaking: YES (ObjectWatcher was watching this because io.flutter.plugins.firebase.messaging.
​ FlutterFirebaseMessagingBackgroundService received Service#onDestroy() callback)
In both cases the background messages work without a problem but I do also get the following messages in the Logcat:
W/FLTFireMsgService: A background message could not be handled in Dart as no onBackgroundMessage handler has been registered.
W/FirebaseMessaging: Notification Channel set in AndroidManifest.xml has not been created by the app. Default value will be used.
My AndroidManifest.xml:
<application
android:name="com.application.test.Application"
android:label="Test App"
android:icon="#mipmap/ic_launcher">
<activity
android:name="com.application.test.MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/notification_color" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id" />
</application>
Any suggestion how to fix the issue?
Related
I made an app using Firebase and Admob, and the Kotlin app, which worked fine, doesn't work after wipe data from the emulator. The error code is as follows.
"The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firebase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date"
I've tried resetting firebase, but it still won't launch. What's wrong?
The build gradle and manifest are attached below.
build gradle(project)
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
// classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.gms:google-services:4.3.13'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build gradle(module)
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.jym.qb"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// implementation platform('com.google.firebase:firebase-bom:30.4.1')
implementation platform('com.google.firebase:firebase-bom:31.1.0')
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.android.gms:play-services-ads:19.6.0'
implementation 'com.google.firebase:firebase-auth-ktx:21.1.0'
implementation 'com.google.android.gms:play-services-auth:20.4.0'
}
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jym.qb">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Qb"
android:name=".SharedValue"
>
<activity
android:name=".ManageQuestionActivity"
android:exported="false" />
<activity
android:name=".KeywardActivity"
android:exported="false" />
<activity
android:name=".UpdateActivity"
android:exported="false" />
<activity
android:name=".GetQuestionActivity"
android:exported="false" />
<activity
android:name=".WorkbookActivity"
android:exported="false" />
<activity
android:name=".PartActivity"
android:exported="false" />
<activity
android:name=".ExamActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxx~xxxxxxxxxxx" />
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
After taking a walk to cool off for an hour, the app works normally. Looking at the Google Admob documentation, I found the following:
"Key Point: New test devices typically start serving test ads in your app within 15 minutes, but it can also take up to 24 hours."
While initializing the data of the virtual emulator, it seems that Admob recognizes it as a new mobile phone and delays the time. Could it be that what I was thinking was correct?
so right now in the app I have a screen(s). The content of that screen(s) holds a link and that link then opens in the browser when I try the dynamic link. It should open the specific screen in the app.
exampleLink
https://mdddk.page.link/?link=https%3a%2f%2fbetamddddkweb.z19.web.core.windows.net%2f%23%2flearning%2ftouchstone%2fee01dba7-c560-4d8d-bc52-15d0efc85252%2f&ibi=org.cicf.mvmt10k&isi=1613969453&apn=org.cccc.mddddk
it literally opens nba.com
meaning a screen with a link to content (nba.com for example) IS WHERE A USER SHOULD BE DIRECTED TO inside the app... BUT INSTEAD IT opens the LINK TO CONTENT in the browser.
trying to figure out if its the config object that is the problem but changing it ACCORDING TO THE DOCS just throws typescript errors and shows no change.
I am testing the links by emailing them to myself on android and trying to open.
one sample screen contains the link on the screen to nba.com. And that is what opens in the browser.
AGAIN changing the below config even copy/pasting from the docs only throws a typescript error.
const config = {
screens: {
CoreNavigator: "/learning/touchstone/:itemId",
},
};
const linking = {
prefixes: [
// Linking.createURL("/"),
"cccc://",
"https://mdddddk.page.link",
"https://*.betamddddkweb.z19.web.core.windows.net",
"https://betamvmnt10kweb.z19.web.core.windows.net",
"https://betamvmnt10kweb.z19.web.core.windows.net/#/",
],
config,
};
const config = {
screens: {
Profile: {
path: 'user/:id/:section',
parse: {
id: (id) => `user-${id}`,
},
stringify: {
id: (id) => id.replace(/^user-/, ''),
},
},
},
}; === typescript errors only
const config = {
screens: {
CoreNavigator: "/learning/touchstone/:itemId",
},
};
const linking = {
prefixes: [
// Linking.createURL("/"),
"cccc://",
"https://mdddddk.page.link",
"https://*.betamddddkweb.z19.web.core.windows.net",
"https://betamddddkweb.z19.web.core.windows.net",
"https://betamdddddkweb.z19.web.core.windows.net/#/",
],
config,
};
const config = {
screens: {
Profile: {
path: 'user/:id/:section',
parse: {
id: (id) => `user-${id}`,
},
stringify: {
id: (id) => id.replace(/^user-/, ''),
},
},
},
}; === typescript errors only
``
<NavigationContainer
linking={linking}
fallback={<Text>Loading...</Text>}
>
<StackNav.Screen
name={ContentScreens.CURRICULUM_DETAIL}
component={TouchstoneDetailScreen}
/>
`
Type '{ prefixes: string[]; config: { screens: { screens: { CoreNavigator: string; }; }; }; }' is not assignable to type 'LinkingOptions<{ screens: unknown; }>'.
The types of 'config.screens.screens' are incompatible between these types.
Type '{ CoreNavigator: string; }' is not assignable to type 'string | Omit<PathConfig<{}>, "screens" | "initialRouteName">'.ts(2322)
NavigationContainer.d.ts(18, 5): The expected type comes from property 'linking' which is declared here on type 'IntrinsicAttributes & NavigationContainerProps & { theme?: Theme; linking?: LinkingOptions<{ screens: unknown; }>; fallback?: ReactNode; documentTitle?: DocumentTitleOptions; onReady?: () => void; } & { ...; }'
sorry for the caps. I'm stuck for days on this. Other than the ts errors I am no longer getting any errors from the links. on the web I was receiving errors about whitelisted links/params but no longer they all open on the web. but in the app They should go to an app screen not that screens linked content.
Links were configured with Expo Rn and Firebase not Reactnative Firebase.
`<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.cicccc.mvddddk">
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"/>
</intent>
</queries>
<application android:name=".MainApplication" android:label="#string/app_name" android:icon="#mipmap/ic_launcher" android:roundIcon="#mipmap/ic_launcher_round" android:allowBackup="true" android:theme="#style/AppTheme" android:usesCleartextTraffic="true">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="46.0.0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/#hhhhh/mdddk"/>
<activity android:name=".MainActivity" android:label="#string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustPan" android:theme="#style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="ccc/>
<data android:scheme="org.cccc.mddddk"/>
</intent-filter>
<intent-filter android:autoVerify="true" data-generated="true">
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="https" android:host="mvmt10k.page.link" android:pathPrefix="/"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.fbook.react.devsupport.DevSettingsActivity" android:exported="false"/>
</application>
</manifest>
Just started learning React-native.
I'm getting stuck on the picker component.
Picker not working on react-native": "0.68.2
I installed it --> npm i #react-native-picker/picker
Imported --> import {Picker} from '#react-native-picker/picker';
But still getting error message
#react-native-picker/picker could not be found within the project or in these directories: node_modules ..\node_modules
Tried a simple program to list languages, not working!
class testingPicker extends Component {
state = {
language:'a'
}
render(){
return(
<View>
<Picker
style={{width:'100%'}}
>
{/* Adding options to picker */}
<Picker.Item label="A" value="a"/>
<Picker.Item label="B" value="b"/>
</Picker>
</View>
)
}
}
export default testingPicker;
User "react-native-picker-select" library for picker in react native
For more details Visit
https://blog.logrocket.com/how-to-use-react-native-picker-select/
I am a developing a bare react native app with react native cli.
I recentlty integrated firebase and installed #react-native-firebase/messaging.
When calling .getToken() of messaging
import messaging from '#react-native-firebase/messaging';
await messaging().getToken() <------------ CAUSING APP TO CLOSE
Everytime I add this line the app closes without any warnings and logs, It dosen't happen when I comment the line
Here's my AndroidManifest.XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.NAME.NAME">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-9772207663610474XXXXXXXXXX"/>
<meta-data
android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="false"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data
android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="#color/white"/> <!-- or #android:color/{name} to use a standard color -->
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
</application>
Here's the Android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
googlePlayServicesVersion = "+"
firebaseVersion = "+"
firebaseMessagingVersion = "+"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}}
Did you add this line to your Android/app/build.gradle?
implementation platform(‘com.google.firebase:firebase-bom:28.0.1’)
If you did, try to remove it, clean, rebuild and run the project again.
firebaseMessagingVersion = "21.1.0"
resolve my issue.
Updating to "#react-native-firebase/messaging": "^11.5.0" in package.json and changing firebaseMessagingVersion = "21.1.0" in the buildscript.ext of android/build.gradle resolved the issue for me.
Check messaging permission before the executing this line.
_checkPermission = async() => {
const enabled = await firebase.messaging().hasPermission();
if (enabled) {
const device = await firebase.messaging().getToken()
console.warn(device)
}
else this._getPermission()
}
_getPermission = async() => {
firebase.messaging().requestPermission()
.then(() => {
this._checkPermission()
})
.catch(error => {
// User has rejected permissions
});
}
I have an Image (that is the size of a banner) that has a background color #F6D401 and needs to go to TopBar, for branding.
in App.xaml I set:
<Application.Resources>
<ResourceDictionary>
<Color x:Key="Primary">#f6d401</Color>
<Color x:Key="TextColor">#5a5a5a</Color>
Then in AppShell.xaml
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="{StaticResource Primary}" />
Then on pages:
<Shell.TitleView>
<Image
HorizontalOptions="Center"
VerticalOptions="Center"
Source="logo.png" />
</Shell.TitleView>
On Android I get a background banner and all the colors the same color, which is exactly what I want and what is expected.
on iOS, however, colors do not seem to match
I am assuming there is a default setting on iOS somewhere that is doing this, that needs to be changed.
How do I make banner and icon colors to match?
Please add UINavigationBar.Appearance.Translucent = false; to AppDelegate.cs
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
UINavigationBar.Appearance.Translucent = false;
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
Here is running screenshot.