urbanairship / airship-flutter

Flutter integration
Other
17 stars 16 forks source link

Badges not showing on iOS devices #88

Closed lo-re-co closed 3 years ago

lo-re-co commented 3 years ago

❗For how-to inquiries involving Airship functionality or use cases, please contact (support)[https://support.airship.com/].

Preliminary Info

What Airship dependencies are you using?

airship_flutter: ^4.3.0

What are the versions of any relevant development tools you are using?

Flutter (Channel stable, 2.2.3), Android Studio (version 4.2)

Report

What unexpected behavior are you seeing?

While push notifications do work, on iOS devices badge won't appear on the app icon when receiving notifications. Sadly the documentation provide only native methods to enable badging/auto-badging and it seems like there are no flutter methods to do so.

What is the expected behavior?

Implementing badging/auto-badging in Flutter code

What are the steps to reproduce the unexpected behavior?

Setup a push receiving app on iOS and send push notifications via a PHP Api

Do you have logging for the issue?

rlepinski commented 3 years ago

Thanks for the feedback, Ill add this request to our work queue

lo-re-co commented 3 years ago

Thanks for the feedback, Ill add this request to our work queue

Thank you, also the flutter SDK doesn't provide a method to reset the badge counter. Working on native swift code it is possible to hide it when the user open the app, but on a new notification message the counter will just increment by 1. (the backend payload is configured to do so).

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
  override func applicationWillEnterForeground(_ application: UIApplication) {
   application.applicationIconBadgeNumber = 0;
  }

  override func applicationDidBecomeActive(_ application: UIApplication) {
      application.applicationIconBadgeNumber = 0;d
  }
}
rlepinski commented 3 years ago

You send absolute values through the payload, not increment. In order to use the increment feature, we have to sync the count from the device to our backend. If you are in native code, you could add a call to UAirship.push().isAutobadgeEnabled = true

lo-re-co commented 3 years ago

You send absolute values through the payload, not increment. In order to use the increment feature, we have to sync the count from the device to our backend. If you are in native code, you could add a call to UAirship.push().isAutobadgeEnabled = true

While this has become clear over numerous trials and errors, a very important feature I'd wish this library had is the possibility to:

Thanks for the reply!

rlepinski commented 3 years ago

The work on our queue is to add the following methods:

You probably will be able to get to the work before we do, so if you wan't to add to the plugin I can help you. The react-native module has these methods already so you could take a look at how that is done.

lore-co commented 3 years ago

While I've already solved this server side I truly appreciate the reactivity and the work you put on your side. Also, nice cat!

P.s. you can mark this thread as closed if you wish so