Sam Barnum
Sam Barnum

Reputation: 10744

Ionic 5 push notifications with Capacitor

My Ionic 5 app wants to send push notifications. The only guide I could find for this is Using Push Notifications with Firebase in an Ionic + Angular App

Why is Firebase necessary? Can I send push notifications without Firebase?

I tried this setup anyway. I didn't get very far.

The guide has this code:

    // Request permission to use push notifications
    // iOS will prompt user and return if they granted permission or not
    // Android will just grant without prompting
    PushNotifications.requestPermission().then( result => {
      if (result.granted) {
        // Register with Apple / Google to receive push via APNS/FCM
        PushNotifications.register();
      } else {
        // Show some error
      }
    });

However, Typescript is complaining that the correct method is requestPermissions() not requestPermission().

Both fail when running in XCode, probably because I didn't set up pods.

What are my options with Ionic 5 + Capacitor for sending push notifications without Firebase?

Upvotes: 5

Views: 7473

Answers (1)

jcesarmobile
jcesarmobile

Reputation: 53361

EDIT:

The guide is now updated to Capacitor 3.

Capacitor 2 guide can be found here

OLD: The guide has been updated to capacitor 2, but capacitor 2 is still in beta.

Install it using next tag

npm install @capacitor/cli@next
npm install @capacitor/core@next
npm install @capacitor/ios@next
npm install @capacitor/android@next

Capacitor uses APNS by default, so if you don’t make the changes in the AppDelegate.swift it should just work.

Upvotes: 5

Related Questions