ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.04k stars 999 forks source link

bug: Local Notifications aren't triggering on iOS / permissions not being requested! #3451

Closed sts-ryan-holton closed 4 years ago

sts-ryan-holton commented 4 years ago

Bug Report

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 2.4.0
  @capacitor/core: 2.4.0
  @capacitor/android: 2.4.0
  @capacitor/electron: 2.4.0
  @capacitor/ios: 2.4.0

Installed Dependencies:

  @capacitor/android not installed
  @capacitor/core 2.4.0
  @capacitor/cli 2.4.0
  @capacitor/ios 2.4.0
  @capacitor/electron not installed

  Found 0 Capacitor plugins for ios:
[success] iOS looking great! 👌

Platform(s)

Current Behavior

Upon triggering a local notification via some JavaScript code on my running emulator, I'm not given a permissions request to use notifications and a notification isn't triggered.

Expected Behavior

Code Reproduction

Attached is some example code from my project (Nuxt JS) and here I'm using async/await, and am trying to catch any errors, I'm never reaching the alert() so assume something else is wrong...

<template>
  <v-layout
    column
    justify-center
    align-center
  >
    <v-flex
      xs12
      sm8
      md6
    >

    <v-btn @click="createNotification">Notification</v-btn>

    </v-flex>
  </v-layout>
</template>

<script>
import { Plugins } from '@capacitor/core';
const { LocalNotifications } = Plugins;

export default {
  methods: {

    async createNotification () {
      try {
        await LocalNotifications.schedule({
          notifications: [
            {
              title: "Title",
              body: "Body",
              id: 1,
              schedule: { at: new Date(Date.now() + 1000 * 5) },
              sound: null,
              attachments: null,
              actionTypeId: "",
              extra: null
            }
          ]
        });
      } catch (err) {
        alert(err)
        Plugins.Modals.alert({
          title: 'Test Alert',
          message: e
        })
      }
    }

  }
}
</script>

Other Technical Details

npm --version output: 6.14.2

node --version output: v10.15.3

pod --version output (iOS issues only): 1.9.3

Additional Context

Tried following an example that someone had posted, the code is correct at least -> https://github.com/bubundas17/capacitor-nuxt-demo/blob/master/pages/index.vue

Looking in Xcode after clicking my button to trigger a notification, I get a few things which suggest it's working, but I never saw the notification...

Screenshot 2020-08-22 at 17 34 45
jcesarmobile commented 4 years ago

It was a breaking change announced on 2.0.0 version release, there is a requestPermission method to request the permissions, you have to request them, it's not automatic anymore

https://github.com/ionic-team/capacitor/releases/tag/2.0.0

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.