Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification not receiving in foreground on IOS #54

Closed
viksat7 opened this issue Apr 20, 2020 · 12 comments
Closed

Notification not receiving in foreground on IOS #54

viksat7 opened this issue Apr 20, 2020 · 12 comments

Comments

@viksat7
Copy link

viksat7 commented Apr 20, 2020

Thanks for the great plugin and being so responsive to the community,

installed 5.1.0 version of the plugin but below problem still persists in my app

  1. Notification is not displayed in both IOS & Android when app is in Foreground
  2. Notification is displayed in both IOS & Android in Background but only Android onNotification method is invoked but IOS doesn't invokes onNotification even in both foreground and background state

Tried with Legacy build, getting no error when notification is pushed or any breakpoint is getting debugged in Xcode on didReceiveRemoteNotification & didReceiveNotificationResponse method (file : AppDelegate+FCMPlugin.m)

If there are any other plugin in my app causing the notification not getting displayed in foreground app or am I missing something in payload json of notification?

below plugins been used

  • cordova-plugin-badge 0.8.8 "Badge"
  • cordova-plugin-camera 4.0.3 "Camera"
  • cordova-plugin-device 2.0.3 "Device"
  • cordova-plugin-disable-ios11-statusbar 1.0.0 "cordova-plugin-disable-ios11-statusbar"
  • cordova-plugin-fcm-with-dependecy-updated 5.1.0 "Cordova FCM Push Plugin"
  • cordova-plugin-file 6.0.2 "File"
  • cordova-plugin-file-transfer 1.7.1 "File Transfer"
  • cordova-plugin-fingerprint-aio 2.0.0 "FingerprintAllInOne"
  • cordova-plugin-geolocation 4.0.1 "Geolocation"
  • cordova-plugin-googlemaps 2.4.6 "cordova-plugin-googlemaps"
  • cordova-plugin-inappbrowser 4.0.0-dev "InAppBrowser"
  • cordova-plugin-iroot 0.8.1 "iRoot"
  • cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
  • cordova-plugin-network-information 2.0.2 "Network Information"
  • cordova-plugin-privacyscreen 0.3.1 "PrivacyScreenPlugin"
  • cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
  • cordova-plugin-secure-storage 3.0.2 "SecureStorage"
  • cordova-plugin-splashscreen 5.0.3 "Splashscreen"
  • cordova-plugin-whitelist 1.3.4 "Whitelist"
  • cordova-plugin-wkwebview-engine 1.2.1 "Cordova WKWebView Engine"
  • ionic-plugin-keyboard 2.2.1 "Keyboard"

notification json being pushed from api

{
    "to": "device token",
    "collapse_key": "green",
    "data": {
        "id": 1
    },
    "notification": {
      "title":"Title Message",
      "body":"Notiifcation Message Content",
       "click_action":"FCM_PLUGIN_ACTIVITY"
    }
}

Xcode log of IOS App

W0420 20:29:32.526099       1 commandlineflags.cc:1503] Ignoring RegisterValidateFunction() for flag pointer 0x104eb1490: no flag found at that address
2020-04-20 20:29:32.547953+0530 My App[630:92960] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/D581DC4B-F6EB-4960-BC11-3AC8D00D75AA/Library/Cookies/Cookies.binarycookies
2020-04-20 20:29:32.581190+0530 My App[630:92960] Apache Cordova native platform version 5.1.1 is starting.
2020-04-20 20:29:32.581346+0530 My App[630:92960] Multi-tasking -> Device: YES, App: YES
2020-04-20 20:29:32.668112+0530 My App[630:92960] WF: === Starting WebFilter logging for process My App
2020-04-20 20:29:32.668163+0530 My App[630:92960] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2020-04-20 20:29:32.668206+0530 My App[630:92960] WF: _WebFilterIsActive returning: NO
2020-04-20 20:29:32.684782+0530 My App[630:92960] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2020-04-20 20:29:32.684844+0530 My App[630:92960] WF: _WebFilterIsActive returning: NO
2020-04-20 20:29:32.690956+0530 My App[630:92960] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2020-04-20 20:29:32.691020+0530 My App[630:92960] WF: _WebFilterIsActive returning: NO
2020-04-20 20:29:32.859686+0530 My App[630:92960] CDVWKWebViewEngine will reload WKWebView if required on resume
2020-04-20 20:29:32.859795+0530 My App[630:92960] Using WKWebView
2020-04-20 20:29:32.860240+0530 My App[630:92960] [CDVTimer][console] 0.145078ms
2020-04-20 20:29:32.860390+0530 My App[630:92960] [CDVTimer][handleopenurl] 0.084996ms
2020-04-20 20:29:32.862052+0530 My App[630:92960] Unlimited access to network resources
2020-04-20 20:29:32.862183+0530 My App[630:92960] [CDVTimer][intentandnavigationfilter] 1.745939ms
2020-04-20 20:29:32.862341+0530 My App[630:92960] [CDVTimer][gesturehandler] 0.108004ms
2020-04-20 20:29:32.862504+0530 My App[630:92960] [CDVTimer][disablestatusbar] 0.097036ms
2020-04-20 20:29:32.864486+0530 My App[630:92960] [CDVTimer][file] 1.910090ms
2020-04-20 20:29:32.866986+0530 My App[630:92960] [CDVTimer][cordovagooglemaps] 2.425075ms
2020-04-20 20:29:32.867216+0530 My App[630:92960] [CDVTimer][inappbrowser] 0.111103ms
2020-04-20 20:29:32.867381+0530 My App[630:92960] [CDVTimer][iroot] 0.072956ms
2020-04-20 20:29:32.867540+0530 My App[630:92960] [CDVTimer][privacyscreenplugin] 0.112057ms
2020-04-20 20:29:32.870459+0530 My App[630:92960] [CDVTimer][splashscreen] 2.835989ms
2020-04-20 20:29:32.871432+0530 My App[630:92960] [CDVTimer][keyboard] 0.824094ms
2020-04-20 20:29:32.871536+0530 My App[630:92960] [CDVTimer][TotalPluginStartup] 11.502028ms
2020-04-20 20:29:32.886780+0530 My App[630:92960] DidFinishLaunchingWithOptions
2020-04-20 20:29:32.921485+0530 My App[630:92960] app become active
2020-04-20 20:29:32.941194+0530 My App[630:92960] IAB.close() called but it was already closed.
2020-04-20 20:29:33.144626+0530 My App[630:92960] [ProcessSuspension] 0x106ee1a40 - ProcessAssertion::processAssertionWasInvalidated()
2020-04-20 20:29:33.145263+0530 My App[630:92960] [ProcessSuspension] 0x106ee19e0 - ProcessAssertion::processAssertionWasInvalidated()
2020-04-20 20:29:33.145354+0530 My App[630:92960] [ProcessSuspension] 0x106ee1980 - ProcessAssertion::processAssertionWasInvalidated()
2020-04-20 20:29:33.146315+0530 My App[630:92960] [ProcessSuspension] 0x106ee1aa0 - ProcessAssertion::processAssertionWasInvalidated()
2020-04-20 20:29:33.483563+0530 My App[630:92960] Device FCM Token: fSGC7S-oak81lcqtbYcD4n:APA91bEDpWZxdiORMq1roz-zAFYYSd0fRiy_XuSAlcKq26MaQ5savjfKKmpgM-66Mutop50svKnQ7ILRwrZiRUyh4MZ1KR_38FF7UYvEaPCa7aNR54F04OXoHHwkZoUwhwlwzaoiGNJp
2020-04-20 20:29:33.585463+0530 My App[630:93209] 6.22.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.
2020-04-20 20:29:33.637146+0530 My App[630:93209] 6.22.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-04-20 20:29:33.637943+0530 My App[630:93209] 6.22.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-04-20 20:29:33.638454+0530 My App[630:93209] 6.22.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60401000 started
2020-04-20 20:29:33.638931+0530 My App[630:93209] 6.22.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2020-04-20 20:29:33.639624+0530 My App[630:93209] 6.22.0 - [Firebase/Analytics][I-ACS025036] App Delegate Proxy is disabled
2020-04-20 20:29:34.286644+0530 My App[630:93140] 6.22.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-04-20 20:29:34.620937+0530 My App[630:93140] 6.22.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2020-04-20 20:29:35.252502+0530 My App[630:92960] Cordova view ready
2020-04-20 20:29:35.363180+0530 My App[630:92960] FCMPlugin.js: is created
2020-04-20 20:29:35.363891+0530 My App[630:92960] FCMPlugin Ready OK
2020-04-20 20:29:35.364356+0530 My App[630:92960] hidePadding android
2020-04-20 20:29:35.364706+0530 My App[630:92960] Ionic Native: deviceready event fired after 1806 ms
2020-04-20 20:29:35.365911+0530 My App[630:92960] {"google":{"maps":{"event":{"MAP_READY":"map_ready","MAP_CLICK":"map_click","MAP_LONG_CLICK":"map_long_click","POI_CLICK":"poi_click","MY_LOCATION_CLICK":"my_location_click","MY_LOCATION_BUTTON_CLICK":"my_location_button_click","INDOOR_BUILDING_FOCUSED":"indoor_building_focused","INDOOR_LEVEL_ACTIVATED":"indoor_level_activated","CAMERA_MOVE_START":"camera_move_start","CAMERA_MOVE":"camera_move","CAMERA_MOVE_END":"camera_move_end","OVERLAY_CLICK":"overlay_click","POLYGON_CLICK":"polygon_click","POLYLINE_CLICK":"polyline_click","CIRCLE_CLICK":"circle_click","GROUND_OVERLAY_CLICK":"groundoverlay_click","INFO_CLICK":"info_click","INFO_LONG_CLICK":"info_long_click","INFO_CLOSE":"info_close","INFO_OPEN":"info_open","MARKER_CLICK":"marker_click","MARKER_DRAG":"marker_drag","MARKER_DRAG_START":"marker_drag_start","MARKER_DRAG_END":"marker_drag_end","MAP_DRAG":"map_drag","MAP_DRAG_START":"map_drag_start","MAP_DRAG_END":"map_drag_end","KML_CLICK":"kml_click","PANORAMA_READY":"panorama_ready","PANORAMA_CAMERA_CHANGE":"panorama_camera_change","PANORAMA_LOCATION_CHANGE":"panorama_location_change","PANORAMA_CLICK":"panorama_click"},"Animation":{"BOUNCE":"BOUNCE","DROP":"DROP"},"Map":{},"StreetView":{"Source":{"DEFAULT":"DEFAULT","OUTDOOR":"OUTDOOR"}},"MapTypeId":{"NORMAL":"MAP_TYPE_NORMAL","ROADMAP":"MAP_TYPE_NORMAL","SATELLITE":"MAP_TYPE_SATELLITE","HYBRID":"MAP_TYPE_HYBRID","TERRAIN":"MAP_TYPE_TERRAIN","NONE":"MAP_TYPE_NONE"},"environment":{},"Geocoder":{},"LocationService":{},"geometry":{"encoding":{},"spherical":{},"poly":{}}}},"notification":{"local":{"core":{"_defaults":{"actionGroupId":null,"actions":[],"attachments":[],"autoClear":true,"badge":null,"channel":null,"color":null,"data":null,"defaults":0,"foreground":false,"group":null,"groupSummary":false,"icon":null,"id":0,"launch":true,"led":true,"lockscreen":true,"mediaSession":null,"number":0,"priority":0,"progressBar":false,"showWhen":true,"silent":false,"smallIcon":"res://icon","sound":true,"sticky":false,"summary":null,"text":"","title":"","trigger":{"type":"calendar"},"vibrate":false,"wakeup":true},"_listener":{}}}}}
2020-04-20 20:29:35.368418+0530 My App[630:92960]  IRoot [object Object]
2020-04-20 20:29:35.374438+0530 My App[630:92960] -canOpenURL: failed for URL: "cydia://package/com.example.package" - error: "This app is not allowed to query for scheme cydia"
2020-04-20 20:29:35.377578+0530 My App[630:92960] -canOpenURL: failed for URL: "cydia://package/com.fake.package" - error: "This app is not allowed to query for scheme cydia"
My App(630,0x10583e040) malloc: can't allocate region
:*** mach_vm_map(size=11846451200, flags: 100) failed (error code=3)
My App(630,0x10583e040) malloc: *** set a breakpoint in malloc_error_break to debug
2020-04-20 20:29:35.378981+0530 My App[630:92960] iOS platform
2020-04-20 20:29:35.379143+0530 My App[630:92960] error JSON.stringify()ing argument: TypeError: JSON.stringify cannot serialize cyclic structures.
2020-04-20 20:29:35.379379+0530 My App[630:92960] file:///private/var/containers/Bundle/Application/89A65B1B-E8C6-42A9-ADFC-267CB24F10F1/My%App.app/www/index.html
2020-04-20 20:29:35.379647+0530 My App[630:92960] dark mode is on
2020-04-20 20:29:35.379832+0530 My App[630:92960] network type wifi
2020-04-20 20:29:35.380013+0530 My App[630:92960] Device is: iPhone8,1
2020-04-20 20:29:35.380272+0530 My App[630:92960] Device UUID is: AAB04DB8-DDE9-4BA6-B3A1-5C44F1FF59B5
2020-04-20 20:29:35.380460+0530 My App[630:92960] app started ...
2020-04-20 20:29:35.380658+0530 My App[630:92960] view registered for notifications
2020-04-20 20:29:35.400064+0530 My App[630:92960] IRoot.isRooted success:  false
2020-04-20 20:29:35.402276+0530 My App[630:92960] -------------------- localstorage did not find 'consectus'
2020-04-20 20:29:35.402655+0530 My App[630:92960] loading dev settings
2020-04-20 20:29:35.403049+0530 My App[630:92960] posting:  /register/registernewcustomer
2020-04-20 20:29:35.403434+0530 My App[630:92960] self.token  false -1587394775397
2020-04-20 20:29:35.403838+0530 My App[630:92960] getting access token
2020-04-20 20:29:35.404324+0530 My App[630:92960] Authorization Code:::::::::::::::
2020-04-20 20:29:35.450771+0530 My App[630:92960] Device FCM Token: dwSTSEilc0ermEDaxTo0mH:APA91bHyfS46aM2EGpGlqFPtNbD-W5mRZPmvaXRcC8lqlEa3cSu_SR1TAkALC-L35bqquB_d5F2wVOUtPgM_g5t0fhig0bKqaqBo3HOWlIumr5lveNUJoo5AYEXMDkyJ_8_ERisQC0OY
2020-04-20 20:29:35.450878+0530 My App[630:92960] notifyFCMTokenRefresh token: dwSTSEilc0ermEDaxTo0mH:APA91bHyfS46aM2EGpGlqFPtNbD-W5mRZPmvaXRcC8lqlEa3cSu_SR1TAkALC-L35bqquB_d5F2wVOUtPgM_g5t0fhig0bKqaqBo3HOWlIumr5lveNUJoo5AYEXMDkyJ_8_ERisQC0OY
2020-04-20 20:29:35.450928+0530 My App[630:92960] stringByEvaluatingJavaScriptFromString FCMPlugin.onTokenRefreshReceived('dwSTSEilc0ermEDaxTo0mH:APA91bHyfS46aM2EGpGlqFPtNbD-W5mRZPmvaXRcC8lqlEa3cSu_SR1TAkALC-L35bqquB_d5F2wVOUtPgM_g5t0fhig0bKqaqBo3HOWlIumr5lveNUJoo5AYEXMDkyJ_8_ERisQC0OY');
2020-04-20 20:29:35.456469+0530 My App[630:92960] refresh token --------------------------- dwSTSEilc0ermEDaxTo0mH:APA91bHyfS46aM2EGpGlqFPtNbD-W5mRZPmvaXRcC8lqlEa3cSu_SR1TAkALC-L35bqquB_d5F2wVOUtPgM_g5t0fhig0bKqaqBo3HOWlIumr5lveNUJoo5AYEXMDkyJ_8_ERisQC0OY
2020-04-20 20:29:36.396084+0530 My App[630:92960] getToken Code XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2020-04-20 20:29:36.397795+0530 My App[630:92960] self.expires_in 7200000
2020-04-20 20:29:36.398309+0530 My App[630:92960] self.expires_in Mon Apr 20 2020 22:29:36 GMT+0530 (IST)
2020-04-20 20:29:36.825040+0530 My App[630:92960] settings written:
2020-04-20 20:29:37.293250+0530 My App[630:92960] self.isForced storage not ==>
2020-04-20 20:29:37.337291+0530 My App[630:92960] settings written:
2020-04-20 20:29:37.338991+0530 My App[630:92960] saved the status of the maxtouhid
2020-04-20 20:29:37.729461+0530 My App[630:92960] dark mode is on
2020-04-20 20:29:37.804862+0530 My App[630:92960] ionViewDidLoad HintPage
2020-04-20 20:29:37.815682+0530 My App[630:92960] settings written:
2020-04-20 20:29:37.841512+0530 My App[630:92960] ionViewDidLoad HintPage
2020-04-20 20:29:38.463909+0530 My App[630:92960] get Token
2020-04-20 20:29:38.470236+0530 My App[630:92960] >>>>>>>>>>>>>>>> device token found >>>>> dwSTSEilc0ermEDaxTo0mH:APA91bHyfS46aM2EGpGlqFPtNbD-W5mRZPmvaXRcC8lqlEa3cSu_SR1TAkALC-L35bqquB_d5F2wVOUtPgM_g5t0fhig0bKqaqBo3HOWlIumr5lveNUJoo5AYEXMDkyJ_8_ERisQC0OY
2020-04-20 20:29:38.886039+0530 My App[630:92960] register device done [object Object]
2020-04-20 20:29:38.905351+0530 My App[630:92960] settings written:
2020-04-20 20:29:40.304650+0530 My App[630:92960] get Token
2020-04-20 20:29:40.323500+0530 My App[630:92960] >>>>>>>>>>>>>>>> device token found >>>>> dwSTSEilc0ermEDaxTo0mH:APA91bHyfS46aM2EGpGlqFPtNbD-W5mRZPmvaXRcC8lqlEa3cSu_SR1TAkALC-L35bqquB_d5F2wVOUtPgM_g5t0fhig0bKqaqBo3HOWlIumr5lveNUJoo5AYEXMDkyJ_8_ERisQC0OY
2020-04-20 20:29:45.544764+0530 My App[630:92960] app become active
2020-04-20 20:29:45.544938+0530 My App[630:92960] Set state foreground
2020-04-20 20:29:45.589341+0530 My App[630:92960] Device APNS Token: c4bc8150c290930a888526cb8376d5913a61e3cad3e42c61717f3049ca059e7c
@andrehtissot
Copy link
Owner

For Android, as you described, as long as the onNotification is called when the app, that was on the background, comes to the foreground because of the notification tapping, it is working as intended.
This way, when the app is on the foreground, you can stylize the message however you want. Like a in app popup or, for example, with https://github.com/katzer/cordova-plugin-local-notifications.

For iOS, thought, it should be reaching onNotification when on foreground or when the notification is tapped. For the iOS issue, I'll investigate.

@viksat7 viksat7 changed the title Notification not receiving in foreground on IOS & Android Notification not receiving in foreground on IOS Apr 20, 2020
@viksat7
Copy link
Author

viksat7 commented Apr 20, 2020

Thanks for the time & for the reply, yes for the android i am using cordova-plugin-local-notification to show notification on foreground since onNotification is working on android both foreground and background

For iOS, my requirement is at-least update the badge when Notification is been received when app is in foreground state hence onNotification should work

@keithj87
Copy link

keithj87 commented Apr 21, 2020

I am seeing the same behavior. It works fine for Android, but not for iOS. I am also looking to trigger local notifications in my iOS app. The local notifications are working fine, when my app is in the foreground, on Android, but nothing is triggered on iOS.

@andrehtissot
Copy link
Owner

andrehtissot commented Apr 22, 2020

@viksat7

The badge-specific issue is addressed as #58

@andrehtissot
Copy link
Owner

@viksat7 Which version of xcode and xcodebuild are you using to build?

@andrehtissot
Copy link
Owner

Could @keithj87 or @viksat7 create a hello world app, of which can be shared here on github? Of which you experience the same issue?

@viksat7
Copy link
Author

viksat7 commented Apr 24, 2020

ok sure give me a day or two as i am busy with work today, will share the github repo of a sample app

@andrehtissot
Copy link
Owner

Issue closed due to inactivity and newer fixes addressing the feature being released in the mean time.

@meghanadixit1
Copy link

Foreground notification still does not work on iOS. Working fine on android.
This happens when I have LocalNotification plugin installed.

if localNotification plugin is uninstalled then the code to handle notification works.
Please look into this.

@andrehtissot
Copy link
Owner

I'll, thank you @meghanadixit1. Knowing this helps a lot.

@andrehtissot
Copy link
Owner

@meghanadixit1 which version of LocalNotification you were installing?

@andrehtissot andrehtissot removed the bug label Jun 4, 2020
@andrehtissot
Copy link
Owner

andrehtissot commented Jun 8, 2020

@meghanadixit1 @viksat7 @keithj87
I have good news. The issue was that this plugin and cordova-plugin-local-notifications were trying to set themselves as the one NotificationCenterDelegate handler.

Now there is a mechanic in place that shares this resource between with other plugins.
Released as v6.4.2, or if you feel adventurous, v7.0.0-beta.1 (for Promise returns and ionic support).

Let me know if upgrading is not enough to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants