14.6 C
Tuesday, May 21, 2024

angular – iOS Capacitor Push Notifications calling the flawed registration callback?

so, in ngOnInit of the welcome-page.part.ts of my angular-ionic app i am calling this:

if (Capacitor.platform !== "internet") { this.registerPush(); }

which is:

`personal async registerPush() {
if (Capacitor.getPlatform() === “android”) {
let permStatus = await PushNotifications.checkPermissions();

  if (permStatus.obtain === "immediate") {
    permStatus = await PushNotifications.requestPermissions();

  if (permStatus.obtain !== "granted") {
    throw new Error("Person denied permissions!");

  await PushNotifications.register();
} else if (Capacitor.getPlatform() === "ios") {
  PushNotifications.requestPermissions().then((consequence) => {
    if (consequence.obtain === "granted") {
    } else {
      console.error("Person denied push notification permissions!");

PushNotifications.addListener("registration", async (token) => {
  console.log("My token: " + token.worth);

  const person = await this.authService.getUserInSession();
  const decryptUser = Globals.decryptOjbectsInSession(person);

      cpf_cnpj: decryptUser.usuario.cpfcnpj,
      reg_key: token.worth,
    .subscribe((response: any) => {
      console.log("response: ", response);

PushNotifications.addListener("registrationError", (error) => {
  console.log("Error on registration: " + JSON.stringify(error));

  (notification) => {
    console.log("Push notification acquired: ", notification);

  (notification) => {
      "Push notification motion carried out",


and that i consider that is precisely accomplished as within the documentation is claimed to. and it DOES work on android, each simulator and bodily machine, it takes the machine token after which registers on my postgres db, in order that i can use API to ship the notification.
enter picture description right here

BUT, for iOS simulator (i haven’t got a bodily one to check) it merely would not work.
ios add listeners
ios doesnt name the best callback

and i do not know the way this works precisely, but it surely seems like it’s calling one other callback. see, the registration callback that i’ve created, is seemingly the “#11279332” one, and when it is referred to as, the one which’s referred to as is the “#11279336” one. on Android, they’re the identical (#102964981)

i attempted following each documentations that i might discover:

put in capacitor/push-notifications and used the command “npx cap sync”

created the firebase undertaking, bought the GoogleService-Information.plist, added in xCode like it’s requested to, and that i additionally added the authkey from apple to the firebase undertaking

added the “pod Firebase/Messaging'” to the Pods file and up to date utilizing “npx cap replace ios”

additionally added the “import Firebase” and the “FirebaseApp.configure()” to the AppDelegate.swift, and each capabilities:

func utility(_ utility: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Information) {
Messaging.messaging().apnsToken = deviceToken
Messaging.messaging().token(completion: { (token, error) in
if let error = error {
    NotificationCenter.default.publish(title: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
} else if let token = token {
    NotificationCenter.default.publish(title: .capacitorDidRegisterForRemoteNotifications, object: token)

func utility(_ utility: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { NotificationCenter.default.publish(title: .capacitorDidFailToRegisterForRemoteNotifications, object: error) }

i’ve used the instructions: “ionic construct” and “npx cap copy”, after which opened the vscode with “npx cap open ios”

i’ve created the apple profile with the push-notifications permission and uploaded it to xcode,
ios profile
enter picture description right here

i additionally enabled the push-notifications functionality inside vscode.

there are a whole lot of steps, and that i consider i’ve accomplished all of them. can somebody inform me what am i doing flawed?

Latest news
Related news


Please enter your comment!
Please enter your name here