I am trying to implement badger count on app launcher icon in flutter for all android based devices. I've tried flutter_app_badger and flutter_dynamic_icon as well but both of them aren't compatible with android. I wan't a unamious solution it's awesome if it works both for android or ios as well.
I am trying to find solutions but there isn't enough data present. Onesignal push notification I am using for the app provides default badge count but it's not in all devices either.
Please help me with the situation.
setLauncherNumber()async{
// set batch number
try {
print('LauncherBadge inside try');
// FlutterAppBadger.updateBadgeCount(10);
await FlutterDynamicIcon.setApplicationIconBadgeNumber(93);
print('LauncherBadge Success');
} catch (e) {
print('LauncherBadge error $e');
}
}
flutter_app_badger and flutter_dynamic_icon arent compatible with all devices
Use this package flutter_app_badger: ^1.5.0
import 'package:flutter_app_badger/flutter_app_badger.dart';
FlutterAppBadger.updateBadgeCount(1);
Related
I've tried the two following approaches to close my ionic app but non has worked.
1.
closeApp(){
this.platform.backButton.subscribeWithPriority(999999, () => {
navigator['app'].exitApp();
})
}
In this approach, when I click on the back button, the app is disappeared, but it's in the list of the background running apps. This doesn't help me, because I need the app to be completely closed and the user be forced to reopen the app by clicking on its icon.
2.
closeApp(){
const { App } = Plugins;
App['exitApp'];
}
in this case, nothing happens, i.e., I stay on the page.
Is there any other approach or plugin which I can use?
I am working with capacitor: 3 and testing on android 12.
import { App } from '#capacitor/app';
ExitApp() {
App.exitApp();
}
try this
I am getting a crash on some android devices when running my Flutter app.
I have been able to debug a release version of the app and this is the only debug output:
W/FlutterJNI(27448): FlutterJNI.loadLibrary called more than once
W/FlutterJNI(27448): FlutterJNI.prefetchDefaultFontManager called more than once
W/FlutterJNI(27448): FlutterJNI.init called more than once
I donĀ“t know where should I begin to look for the reason of the issue.
The device is showing a gray screen and stops working.
Wherever you create the firebaseMessagingBackgroundHandler, annotate it with #pragma('vm:entry-point') like this:
#pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
}
The reason is explained here:
https://github.com/firebase/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart#L46
Flutter Driver code has to tap on the native "Allow" button to continue and simulate the correct user behaviour.
See this screenshot. Native iOS popup before app starts - Allow Notifications
App has not yet completely started and is waiting for this tap.
How does one get the driver to tap on the native iOS popup?
Any suggestions and ideas are welcome.
Here is the code for one attempt to wait for the app before continuing with other tests; it just awaits indefinitely:
setUpAll(() async {
driver = await FlutterDriver.connect();
await driver.waitUntilFirstFrameRasterized();
});
Here is another attempt at finding the word "Allow" in the popup and tapping on it:
test('Allow app to send Notifications.', () async {
final allow = find.byTooltip("Allow");
await delay(750);
await driver.tap(allow);
});
It does not find the word.
The issue is probably that Flutter Driver is not aware of the iOS native popup.
Other tests are very simple once in the app, for example, to tap on fields, enter text, scroll pages, etc.
Any ideas on how to do this?
Unfortunately this feature is currently not possible. Flutter Driver can't interact with native elements (v1.20.4).
https://github.com/flutter/flutter/issues/34345
https://github.com/flutter/flutter/issues/12561
I'd like to update Firestore document every day at 6 AM automatically.
For instance, there is a quote app and update quote to a new one every morning so that the user can see the different quotes.
I don't mind whether executing code on an iOS device or Android because I have both phones.
But I want an app to update the document even if I'm sleeping.
What is the best way of doing this?
Good news it is somewhat possible.
Background Tasks in a nutshell
On Android you would use WorkManager.
You can ask the Android framework to schedule your task somewhere in the future (exact hours are not supported).
On iOS you enable Background Fetch in XCode or manually edit the Info.plist file.
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
</array>
</key>
WorkManager Plugin
Since there is a lot of ceremony to wire everything together there is a handy Flutter plugin which helps you.
The flutter_workmanager plugin supports both WorkManager and performFetch in one unified Dart API.
void callbackDispatcher() {
Workmanager.executeTask((backgroundTask) {
switch(backgroundTask) {
case Workmanager.iOSBackgroundTask:
case "firebaseTask":
print("You are now in a background Isolate");
print("Do some work with Firebase");
Firebase.doSomethingHere();
break;
}
return Future.value(true);
});
}
void main() {
Workmanager.initialize(callbackDispatcher);
Workmanager.registerPeriodicTask(
"1",
"firebaseTask",
frequency: Duration(days: 1),
constraints: WorkManagerConstraintConfig(networkType: NetworkType.connected),
);
runApp(MyApp());
}
Sorry, in this case you will need use WorkManager on Android. This is a way to use background service for that case. In iOS I don't know how.
I think that is not possible to create background services in Flutter because it's run in other context.
I need a view in my app to refresh everytime the app comes back to the foreground. The code below is working perfectly with Android but nothing happens on iOS.
$ionicPlatform.on('resume', function() {
if($state.current.name == "app.listar_aprovacoes"){
// code to refresh scope and view.
};
});
I also tried the following and it also doesn't work with iOS:
document.addEventListener("resume", function() {
var alertPopup = $ionicPopup.alert({
title: 'Foo',
template: 'Bar'
});
}, false);
So could you help me out with a solution to this problem?
Thanks!
EDIT: For some reason, updating the platform using ionic platform update ios didn't update the code for this. I removed the platform and added it again and it started working.
Try using window.addEventListener('resume', callback); as well.
Also make sure you have the Cordova Device Plugin.
You can install it by using:
ionic plugin add cordova-plugin-device
Generally, with the plugin installed, the first ($ionicPlatform.on('resume', ...)) method should work. I tested both on iOS and Android.
For some reason, updating the platform using ionic platform update ios didn't update the code for this. I removed the platform and added it again and it started working.