customerio / customerio-flutter

Flutter plugin for Customer.io
https://www.customer.io/docs/sdk/flutter/getting-started/
MIT License
12 stars 10 forks source link

iOS handle deeplink from push notification not working #128

Closed EstevaoCoelhoRobbin closed 3 weeks ago

EstevaoCoelhoRobbin commented 4 weeks ago

Related: https://github.com/customerio/customerio-flutter/issues/35

Using a iOS device when I click in push notification, app is opened but don't navigate to deeplink. Using a Android device works normally. It's an Flutter App, using customer_io: ^1.3.1 version:

All other things like push status tracking are working normally.

here is my ios/Podfile:

platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  pod 'CustomerIO/MessagingPushFCM', '~> 2.13' # install production build

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
     # adding to fix this issue: https://github.com/DataDog/dd-sdk-flutter/issues/480
      target.build_configurations.each do |config|
        if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 12.0
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      end
    end
  end
end

target 'NotificationServiceExtension' do
  use_frameworks!
  pod 'CustomerIO/MessagingPushFCM', '~> 2.13' # install production build
end

my ios/AppDelegate.swift file:

import UIKit
import Flutter
import IDwallToolkit
import CioMessagingPushFCM
import CioTracking
import FirebaseMessaging
import FirebaseCore

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        GeneratedPluginRegistrant.register(with: self)

        // Set FCM messaging delegate
        Messaging.messaging().delegate = self

        // This line of code is required in order for the Customer.io SDK to handle push notification click events.
        // We are working on removing this requirement in a future release.
        // Remember to modify the siteId and apiKey with your own values.
        // let siteId = "YOUR SITE ID HERE"
        // let apiKey = "YOUR API KEY HERE"
        CustomerIO.initialize(siteId: "OMITTED", apiKey: "OMITTED", region: Region.US) { config in
            // To confirm that `delivered` push metrics are tracked, set this to true.
            config.autoTrackPushEvents = true
            config.logLevel = .debug
        }
        // Initialize Customer.io push features after you initialize the SDK:
        MessagingPushFCM.initialize { config in
            // Automatically register push device tokens to the Customer.io SDK
            config.autoFetchDeviceToken = true
            // When your app is in the foreground and a push is delivered, show the push
            config.showPushAppInForeground = true
        }

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }

    func application(application: UIApplication,
                     didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Messaging.messaging().setAPNSToken(deviceToken, type: .unknown);
    }
    override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
    }
}

extension AppDelegate: MessagingDelegate {
    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
        // Send the FCM token to Customer.io
        MessagingPush.shared.messaging(messaging, didReceiveRegistrationToken: fcmToken)
    }
}

MY pubspec.yaml file:

name: APP_NAME
description: APP_DESC
version: APP_VERSION

environment:
  sdk: "3.4.1"

dependencies:
  flutter:
    sdk: flutter
  {MY_MODULES}

  customer_io: ^1.3.1
  webview_flutter: 4.7.0
  firebase_crashlytics: ^3.5.5
  intl: ^0.18.0
  firebase_core: ^2.31.0
  firebase_remote_config: ^4.4.5
  firebase_messaging: ^14.9.2
  firebase_analytics: ^10.10.5

dependency_overrides:
  test_api: 0.7.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: 2.4.9
  injectable_generator: 2.6.1
  flutter_lints: 2.0.2
  melos: 6.0.0
tawfekov commented 3 weeks ago

we are affected in this bug too

ansshkki commented 3 weeks ago

I have the same issue

levibostian commented 3 weeks ago

Thank you everyone who reported this to us and provided all these great. Sorry to hear you have experienced this issue.

Based on the information provided, this appears to be a new issue that we are currently aware of and are in the process of fixing. To help us diagnose the problem more accurately, could you please send your SDK debug logs to win@customer.io? Be sure to capture all of the logs starting from when the app opens through when a push is received and clicked in your app.

As a temporary workaround, we recommend removing FlutterFire from your app and using only the Customer.io SDK to receive push notifications. We understand that this may not be the most convenient solution, but please be assured that we are actively working on a permanent fix for this issue.

Thank you for your patience and cooperation.


Oh, and disregard the status of this ticket as "not planned". That's for internal tracking, only. We are aware of this issue and will keep you updated on it.

levibostian commented 3 weeks ago

Bug fix is in production.

Follow these docs to update the SDK version and make new builds of your app. Be sure to follow all of the steps in that doc, not just the Flutter pubspec step.

Thank you again for reporting this to us. Hope the new version fixes your issue. Come back to us if it doesn't.