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

Not working in Ionic 2 #1219

Closed
sahildaga95 opened this issue Feb 20, 2017 · 17 comments
Closed

Not working in Ionic 2 #1219

sahildaga95 opened this issue Feb 20, 2017 · 17 comments

Comments

@sahildaga95
Copy link

sahildaga95 commented Feb 20, 2017

Your Environment

Plugin version: latest
Platform: android/ios
Device manufacturer / model: Samsung ON5
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.0
OS: Linux 4.4
Node Version: v7.4.0

Expected Behavior

Tell us what should happen
Plugin should notify with sound if no sound file path is provided.On click Behaviours not working.Plugin should display image as logo and sound file when specified path.Backdated Notifications not getting displayed immediately.

Actual Behavior
None of the above is working.

Tell us what happens instead
Notification triggers with no sound and image

Steps to Reproduce
Install plugin - ionic plugin add de.appplant.cordova.plugin.local-notification

Reproduce this issue; include code to reproduce, if relevant
Home.ts

import { LocalNotifications } from 'ionic-native';


   showNotification() {
    LocalNotifications.schedule({
      id: 1,
      text: 'Single LocalNotification',
      sound: 'file://assets/Notification.mp3',
      icon: 'file://assets/icon.png'
    });
  }

Home.html
<button ion-button color="secondary" (click)="showNotification()">Show Notification</button>
Context
Features like sound and image were working till Ionic was in Beta Version after the RC and Final Release none of them are working properly.

What were you trying to do?
I was implementing the plugin for my application for reminder related notifications.

Debug logs
There are No debug logs of error

@rwillett
Copy link
Collaborator

  1. Please update the template with the correct version of the plugin. The phrase "latest" means nothing if another version is released and is then confusing.

  2. It would be helpful if you used markdown to format the template so its easy to see the code.

  3. It appears that this was working in one version of Ionic and then not in Ionic V2. Since the plugin hasn't changed between the Ionic versions, it does suggest that the Ionic team has changed something. Have you raised this with them?

  4. Also when you schedule notifications, schedule them as an array of JSON objects even if there is only one.

  5. What version of Android?

  6. What other plugins are you using?

  7. Have you created a simple Ionic 2 project just with this plugin and tried that?

@sahildaga95
Copy link
Author

Sorry for replying late.I was out for a while
Answers:-

  1. Plugin Version - 0.8.4
  2. Updated the comment and will keep note from next time.
  3. No , Since on a previous ocassion they asked me to raise the issue with the library.
    Also during the pre-release version i faced some issues.
    Reported here: Past Date notification not getting triggered #1097
  4. Okay will try that too. But the above code is also expected to work right ?
  5. Android Versions - 6.0.0 and alse tried on 6.0.1
  6. & 7. I Created a simple project with Ionic 2 and istalled only this Plugin before reporting the issue.

@rwillett
Copy link
Collaborator

I don't use Ionic 2 so its difficult to say. I would try the ios10 branch as that may (or may not) help with Android. I'm not the plugin author though.

The above code should work but we put everything in arrays.

If it worked in Ionic 2 beta and not in Ionic 2 Release then it does point to the Ionic 2 and Local Notifications not working together.

@erangeles
Copy link

@rwillett run cordova prepare after doing a fresh reinstall of the plugin.

@rwillett
Copy link
Collaborator

@erangeles

Can you explain your comment. We don't run Ionic 2 so we don't have the problem. Who is your comment aimed at?

@sahildaga95
Copy link
Author

@erangeles - didn't work !!

@apfelstyle
Copy link

@sahildaga95 Please try to set the ID as a string

showNotification() {
    LocalNotifications.schedule({
      id: '1',
      text: 'Single LocalNotification',
      sound: 'file://assets/Notification.mp3',
      icon: 'file://assets/icon.png'
    });
  }

@sahildaga95
Copy link
Author

@apfelstyle - According to the documentation here .It should be a Number, not a string.

@apfelstyle
Copy link

@sahildaga95
Do you tried it? When I use a Number the notifications only fire when the app is in the background. If it is a string they also fire when the app is in foreground. Try it.

@rwillett
Copy link
Collaborator

rwillett commented Mar 1, 2017

We never use a string, only a number.

@sahildaga95
Copy link
Author

@apfelstyle - As I have stated in the first comment, the issue is regarding sound and logo.Along with the OnClick events which aren't firing. Not in the context of Scheduling & what you have mentioned seems like a bug to me rather than a solution.

@rwillett
Copy link
Collaborator

Is this still an issue?

@sahildaga95
Copy link
Author

@rwillett - Yes it is,I am awaiting response.

@sahildaga95
Copy link
Author

@rwillett - Did you get time to look at my issue?

@rwillett
Copy link
Collaborator

I am not the author of the plugin.

@swapnilgajbhiyesyne
Copy link

I am facing the same problem.Notification is set properly but not showing on android device.
What is the role of this code:

if(this.platform.is('cordova')){

    // Cancel any existing notifications
    this.localNotifications.cancelAll().then(() => {

        // Schedule the new notifications
        this.localNotifications.schedule(this.notifications);

        this.notifications = [];

      

    });

@katzer
Copy link
Owner

katzer commented Oct 31, 2017

Please try with 0.9-beta. Be aware that the current Ionic wrapper does not work with 0.9-beta. Because many are using the plugin+ionic I will contribute to the ionic-native wrapper in future.

But for now I am closing all ionic related tickets because they point to old code and/or Ionic.

@katzer katzer closed this as completed Oct 31, 2017
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

6 participants