OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
616 stars 213 forks source link

Apns Delegate Never Fired in Flutter iPhone Version #220

Closed shuvojit007 closed 4 years ago

shuvojit007 commented 4 years ago

Description:

Hello, Everyone. I am developing ios app with flutter and using onesignal.com for push notification

image ☝️ But I got this issue on OneSignal Dashboard. I am not sure what is this issue.

Environment OneSignal Flutter SDK version: 2.3.4 Xcode Version :11

Steps to Reproduce Issue:

  1. Install the OneSignal Flutter SDK using pub into your project
    1. Initialize the SDK using OneSignal.shared.init with my app id
    2. Attempt to receive a push notification
    3. Didn't get any notification then I checked with playerid in OneSignal Dashboard and got this message: Apns Delefate Never Fired

My pod file

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

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

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  generated_key_values = {}
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) do |line|
    next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
    plugin = line.split(pattern=separator)
    if plugin.length == 2
      podname = plugin[0].strip()
      path = plugin[1].strip()
      podpath = File.expand_path("#{path}", file_abs_path)
      generated_key_values[podname] = podpath
    else
      puts "Invalid plugin specification: #{line}"
    end
  end
  generated_key_values
end

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  # Flutter Pod

  copied_flutter_dir = File.join(__dir__, 'Flutter')
  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
    unless File.exist?(generated_xcode_build_settings_path)
      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end
    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

    unless File.exist?(copied_framework_path)
      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
    end
    unless File.exist?(copied_podspec_path)
      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
    end
  end

  # Keep pod path relative so it can be checked into Podfile.lock.
  pod 'Flutter', :path => 'Flutter'

  # Plugin Pods

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.each do |name, path|
    symlink = File.join('.symlinks', 'plugins', name)
    File.symlink(path, symlink)
    pod name, :path => File.join(symlink, 'ios')
  end
end

target 'OneSignalNotificationServiceExtension' do
   use_frameworks!
   pod 'OneSignal', '>= 2.9.4', '< 3.0'
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end
jkasten2 commented 4 years ago

@shuvojit007 Please see the OneSignal troubleshooting guide on this as it most likely is a network connection issue to Apple's Sandbox server. https://documentation.onesignal.com/docs/troubleshooting-ios#section-apns-delegate-never-fired

It is possible there is a conflicting library if you seeing the issue consistently between a number of devices. If so reply with a list of the flutter libraries and versions you are using. The Podfile you post won't include them. Lastly I recommend trying to reproduce the problem with a new flutter project to narrow down which one is causing the issue.

shuvojit007 commented 4 years ago

My Flutter libraries are listed below 👇

name: ProgrammingHero
version: 1.0.0+1
environment:
  sdk: ">=2.2.2 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  rxdart: ^0.22.0
  google_sign_in:

  sembast: ^1.16.0+1
  path_provider: ^1.1.0
  shared_preferences: ^0.5.3+1

  #cached_network_image: ^1.1.3
  cached_network_image: ^2.0.0-rc

  #Firebase Dependency
  firebase_auth: ^0.15.3
  cloud_firestore: ^0.12.6
  firebase_database: ^3.0.7

  #Sign in
  apple_sign_in: ^0.1.0
  flutter_auth_buttons: ^0.6.0

  #One Signal
  onesignal_flutter: ^2.3.4

  #design
  shimmer: ^1.0.0
  flutter_html: ^0.11.0
  webview_flutter: ^0.3.10+3

  rich_code_editor: ^0.2.9
  dynamic_theme: ^1.0.1

  #NetWorking
  dio: ^2.1.16

  #Toast
  fluttertoast: ^3.1.0

  progress_dialog: ^1.1.0+1
  device_info: ^0.4.0+2
  share: ^0.6.2+1
  url_launcher: ^5.1.2

  #Image Picker and Cropper
  image_cropper: 1.0.2
  image_picker: 0.6.0+17

  #Flutter Bloc
  flutter_bloc: ^0.21.0

  equatable: ^0.5.1
  #flame
  flame: ^0.15.1
  introduction_screen: ^1.0.6

  flare_flutter: ^1.5.8

  pull_to_refresh: ^1.5.6
  like_button: ^0.1.9
  #folder picker
  folder_picker: ^0.2.1

  #type writer
  animated_text_kit: ^1.3.1
  worm_indicator: 0.2.4

  audioplayers: ^0.13.0
  flushbar: ^1.9.0

  timeago: ^2.0.19
  flutter_linkify: ^2.1.0
  font_awesome_flutter: ^8.5.0

  #get_it: ^3.0.0+1
  get_it: ^3.0.3

  firebase_admob: ^0.9.0+7
  simple_animations: ^1.3.3

  image_downloader: ^0.19.0
  flutter_facebook_login: ^3.0.0
  in_app_purchase: ^0.2.1+4

  connectivity: ^0.4.5+3

  http_server: ^0.9.8+1
  flutter_inappwebview: ^2.1.0+1
#  local_assets_server: ^1.0.1

flutter_icons:
    android: "launcher_icon"
    ios: true
    image_path: "assets/img/icon.png"

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: "^0.7.3"

flutter:

  uses-material-design: true

  assets:
    - assets/img/
    - assets/img/hero/
    - assets/settings/
    - assets/json/
    - assets/js/highlight.js
    - assets/sounds/
    - assets/images/

  fonts:
    - family: Hearticon
      fonts:
        - asset: fonts/hearticon.ttf
    - family: GalaxyIcon
      fonts:
        - asset: fonts/Galaxy.ttf

    - family: CustomIcons
      fonts:
        - asset: fonts/CustomIcons.ttf

    - family: Montserrat
      fonts:
        - asset: fonts/Montserrat-SemiBold.ttf

    - family: Poppins
      fonts:
        - asset: fonts/poppinsbold.ttf
        - asset: fonts/poppinsmedium.ttf
        - asset: fonts/poppinsregular.ttf
        - asset: fonts/poppinssemibold.ttf

    - family: Bebas
      fonts:
        - asset: fonts/bebas.ttf

I also checked the OneSignal troubleshooting guide very carefully and everything seems ok to me

changfeifan commented 4 years ago

I have the same issue when i used this sdk in my flutter project. I can get two types of issues .Other Apns 3000 Error or Apns Delegate Never Fired

jkasten2 commented 4 years ago

@shuvojit007 Thanks for the list of plugins, I don't see any push or notification related plugins, however it is possible one or may still be using and swizzling UNUserNotificationCenterDelegate in an incorrect way and causing the issue. I recommend any of the following ot find the root of your issue:

  1. Create a new Flutter project and just OneSignal.
    • If this works add your plugins in a binary search pattern.
  2. Attempt to run your existing project on different devices and networks.
  3. Confirm your connection issue with Apple's by viewing the device logs noted in https://github.com/OneSignal/OneSignal-iOS-SDK/issues/514#issuecomment-591011919
jkasten2 commented 4 years ago

@changfeifan The "Apns 3000 Error" will happen if your app does not have the "Push Notification" capabilities enabled for your bundle id. Please double check you have followed step "3. Add Required Capabilities (iOS)". If this is already check I recommend toggling it to ensure it gets provisioned correctly.

For the "Apns Delegate Never Fired" please see my https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/220#issuecomment-603468236 above.

rgomezp commented 4 years ago

Closing due to inactivity

bagintz commented 4 years ago

@shuvojit007 Did you ever get your issue figured out, I am getting the APNS Delegate Never Fired also and my setup seems good. I am wondering what you found?

bagintz commented 4 years ago

For whoever finds this, it seemed it was a DNS issue for me, found a suggestion here:

https://stackoverflow.com/a/61075675

shuvojit007 commented 4 years ago

@jkasten2 I already go through your step and its seems like the problem in ios 13. Because it works fine in lower os.

shuvojit007 commented 4 years ago

Screen Shot 2020-05-01 at 9 16 47 PM

This problem occurs when I updated my iPhone os version to 13.3.1 @jkasten2

shuvojit007 commented 4 years ago

@bagintz not yet....still looking for a solution

bagintz commented 4 years ago

@shuvojit007 try the DNS change, just for giggles. I was sure it wouldn't work and it did!

shuvojit007 commented 4 years ago

@bagintz you mean change the dns of my internet provider?

bagintz commented 4 years ago

@shuvojit007 no, on the iOS device that is having problems (https://appleinsider.com/articles/18/04/22/how-to-change-the-dns-server-used-by-your-iphone-and-ipad)

shuvojit007 commented 4 years ago

@bagintz No, it didn't work. I think the actual problem on the ios 13

shuvojit007 commented 4 years ago

@rgomezp is there any update

rgomezp commented 4 years ago

@shuvojit007 , Unfortunately not. This looks like it's not a OneSignal issue, but rather something Apple has to fix. Read more about this ongoing problem here. We are leaving that issue open for visibility