capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

No Way to Prevent Local Notification on Android from Opening the Application

Open brandiwerner opened this issue 4 years ago • 12 comments

Bug Report

Plugin(s)

Capacitor Version

Latest Dependencies:
@capacitor/cli: 3.0.1
@capacitor/core: 3.0.2
@capacitor/android: 3.0.2
@capacitor/electron: 3.0.2
@capacitor/ios: 3.0.2

Installed Dependencies:
@capacitor/cli: 2.4.2
@capacitor/core: 2.4.2
@capacitor/android: 2.4.2
@capacitor/electron: not installed

Platform(s)

Android

Current Behavior

I am using Local Notification Action types and one of those types needs to run code but NOT open the app. Using the props destructive and foreground works to make ios notification actions not open the app but not android. Is there a similar way to make android actions not open the application?

Expected Behavior

When an action on a notification is clicked on android the action should not open the app if specified in the code.

Code Reproduction

This stack overflow shows the code: https://stackoverflow.com/questions/66093556/how-to-prevent-local-notifications-in-capacitor-js-from-opening-the-application?r=SearchResults

Other Technical Details

Additional Context

brandiwerner avatar Jul 09 '21 15:07 brandiwerner

This plugins are for capacitor 3, you are still using capacitor 2. please, migrate to capacitor 3 and provide a sample app reproducing the issue.

jcesarmobile avatar Jul 13 '21 08:07 jcesarmobile

There is no way right now I can upgrade to capacitor 3. Is it expected that android notification should be able to create an action without opening the app?

brandiwerner avatar Jul 14 '21 17:07 brandiwerner

As I said above I will not be able to upgrade to capacitor 3. Is capacitor 2 not supported anymore? I will create a sample app using capacitor 2.

brandiwerner avatar Jul 14 '21 19:07 brandiwerner

Here is the sample app you requested. I ended up using capacitor 3 to make this sample app though I still cannot update my teams code from v2 to v3 at this time.

Github project: https://github.com/brandiwerner/SampleCapacitorAndroidLocalNotifications

Capacitor Doctor Results:

Latest Dependencies:       

  @capacitor/cli: 3.1.1    
  @capacitor/core: 3.1.1   
  @capacitor/android: 3.1.1
  @capacitor/ios: 3.1.1    

Installed Dependencies:    

  @capacitor/core: 3.1.1
  @capacitor/cli: 3.1.1 
  @capacitor/android: 3.1.1
  @capacitor/ios: 3.1.1

brandiwerner avatar Jul 15 '21 15:07 brandiwerner

Here are two videos showing the issue:

https://user-images.githubusercontent.com/17693648/125819572-dd789656-57a3-4931-b3aa-3746ac933c94.mp4

https://user-images.githubusercontent.com/17693648/125819774-3af7379c-df8a-4315-9fce-04506e7b2474.mp4

brandiwerner avatar Jul 15 '21 16:07 brandiwerner

seeing same issue. any update?

NichoBridge214 avatar Jul 19 '21 15:07 NichoBridge214

@jcesarmobile Any update on if this is an expected issue or a bug?

brandiwerner avatar Jul 21 '21 14:07 brandiwerner

Any update on this ? Obviously this is only an issue for Android as the 'destructive' flag on the action hooks up correctly for IOS. There doesn't seem to be any similar code for Android - thus the issue.

MadEddieFFS avatar Apr 19 '22 11:04 MadEddieFFS

Any Update?

FlueschPluesch avatar May 29 '22 17:05 FlueschPluesch

no updates?

Joseilm avatar Mar 31 '23 09:03 Joseilm

I suggest you try NativeScript for Capacitor so you can use the NativeScript Local Notifications plugin, which seems much more mature than this one and has much better Android support.

Erudition avatar May 10 '23 02:05 Erudition