Coder Social home page Coder Social logo

Comments (5)

cwomack avatar cwomack commented on June 12, 2024

Hello, @seokjeatuiti 👋. Can you clarify what version of Android you're using and if you're seeing this on both physical devices and emulators? I wasn't able to reproduce this on more recent versions of Android, so if you could also provide your frontend code that's reproducing this issue it would be appreciated! I think we need to know where you're calling the Push Notification API's in the notification lifecycle/state of the app.

from amplify-js.

seokjeatuiti avatar seokjeatuiti commented on June 12, 2024

@cwomack

Thank you for answer! We have provided answers for each item you asked.

Can you clarify what version of Android you're using and if you're seeing this on both physical devices and emulators?

Yes it's happening on both physical device and emulator.

  • Physical device: Android 14 (Galaxy S23+, Galaxy A53)
  • Emulator: Pixel 2 API 33

I wasn't able to reproduce this on more recent versions of Android, so if you could also provide your frontend code that's reproducing this issue it would be appreciated!

When notifications were being cut off, the settings were as follows.
For reference, We provide both OTP for general users and USER_SRP_AUTH authentication methods for employees.

import { Amplify } from '@aws-amplify/core';
import awsConfig from './aws-exports';
import { Auth, Notifications, Analytics } from 'aws-amplify';

Amplify.configure({
  ...awsConfig,
  Auth: {
    authenticationFlowType: 'USER_SRP_AUTH',
  },
  Analytics: {
     disabled: false
  },
});

  Notifications.Push.enable();
};

I was suspicious that Analytics might be causing a problem with the endpoint, so I added Analytics.disable(), notifications started coming in fine from then on. I referred to this document.

Amplify.configure({
  ...awsConfig,
  Auth: {
    authenticationFlowType: 'USER_SRP_AUTH',
  },
  // Analytics: {
  //   disabled: false
  // },
});
  
  Analytics.disable();
  Notifications.Push.enable();
};

The identifyUser part is as follows.
optOut is not separately specified in the v5 official document, but when this part was excluded at first, there was a problem with the endpoint being created as optOut: All.

export const updatePushToken = async (userId: string) => {
  const token = await AsyncStorage.getItem('pinpointToken');
  if (token) {
    try {
      const userProfile: AWSPinpointUserInfo = {
        optOut: 'NONE',
      };
      await Notifications.Push.identifyUser(userId, userProfile);
    } catch (e) {
      console.error('updateEndpoint ERR', e);
    }
  }
};

I think we need to know where you're calling the Push Notification API's in the notification lifecycle/state of the app

We are sending notifications using pinpoint SDK through Lambda. There doesn't seem to be any particular problem in this part.

const AWS = require('aws-sdk');
const pinpoint = new AWS.Pinpoint({ region: 'us-west-2' });
...

const defaultMessage = {
  Action: 'OPEN_APP',
  Body: message,
  SilentPush: false,
  Title: senderName || '{Service Name}',
  Data: {
    conversationID,
  },
};

const sendMessagesParams = {
    ApplicationId: projectId,
    SendUsersMessageRequest: {
      Users: notifiedUsers,
      MessageConfiguration: {
        DefaultPushNotificationMessage: {
          ...defaultMessage,
        },
        APNSMessage: {
          Badge: 1,
          Priority: '10',
          Sound: 'default',
          ThreadId: senderId,
        },
        GCMMessage: {
          Priority: 'high',
          Sound: 'default',
        },
      },
    },
  };

  await new Promise((resolve, reject) => {
    pinpoint.sendUsersMessages(
      sendMessagesParams,
      (sendMessagesErr, sendMessagesData) => {
        if (sendMessagesErr) {
          reject(sendMessagesErr);
        }
        if (sendMessagesData) {
          resolve(sendMessagesData);
        }
      },
    );
  });
}

By the way, this is an old post, but I experienced a similar problem once in the past, and registered an issue at that time. Please note.

from amplify-js.

nitbk502 avatar nitbk502 commented on June 12, 2024

Hello, I am encountering the same problem. Here are the CloudWatch logs:
2024-03-29T16:30:45.379Z 6a9370ac-fa6e-5925-8e45-2e2c148de650 INFO recipientResult { 'f1c91d2a-1236-408e-9d89-823185a51140': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"2421628289060879526\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'e5J1QAnFTPC0UmggiGi2qr:APA91bH3bGv5G4AsKWX6uPqiH7_uSEe0y_SxDBLDl09r8XehJUaX9Pl3RcIGoZZ6D-pWX3qVAhykeNgCFMuF6Mosy9qL20TzBiP8zXN6zbHj88iO64TGjBTWWBu4dTFqgwOj6c--kys9' }, '5b13560a-f123-42d5-a58d-d04768d9246c': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"6799976235612541133\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'eOZAYcL7SdaJiEyflrezSi:APA91bEsxIdFA0Gxk64sZ-m9L_5LZkbmn-mmQhAu4tC1tXZ4QGm-KSDZjosqeJg-qXvXJn4Y1inNdc9ygzZTImZN50OWkvJ0udQjLHwWC7J_BOB7DeIwQvjvo9aIjOsmPWLTYbFxtB86' }, '35124492-4045-4a64-99fb-cb2774b05a00': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"1526660718498104442\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'eC-us18cQxaLZHJ__m7bEz:APA91bHaV6Y9P1aqo34fxgnyCnOun_13F0w4h2sE8VtDnieZMaj2srZbqwtkkuLTt72sF0F5o9_ebzH9Qn6JdnNdDUJzOoBIm3jtNBf3fElFYOpVrZoEzRnSBc2HpY2VWljOESD0YMZv' }, 'cc0b8944-2ccf-4fa0-8ca2-e36c4986a7cc': { DeliveryStatus: 'PERMANENT_FAILURE', StatusCode: 410, StatusMessage: '{"errorMessage":"Unregistered or expired token","channelType":"GCM","pushProviderStatusCode":"200","pushProviderError":"NotRegistered","pushProviderResponse":"{\\"multicast_id\\":\\"3866949699306559810\\",\\"success\\":0,\\"failure\\":1,\\"canonical_ids\\":0,\\"results\\":[{\\"error\\":\\"NotRegistered\\"}]}"}', Address: 'ejd8IArJSy2-WLmp1IzxEw:APA91bGpOcYzg8QsGqFvTq0-hec_wDh-XIb5hP9Btq5Og1Y-_vO1NtxlWIzD6va-wUiBODwrIoK6oa9-_hl84cJiaMLzGeVCIeU-zAtuuzrioqlb4n06kRHJQDLrr9gt3GiOjTXczVl6' } }

from amplify-js.

cwomack avatar cwomack commented on June 12, 2024

@seokjeatuiti, is the token address in the error messages is the same one that you are using to send from the Firebase console? Any chance you can you share a couple of failures from the same device if possible? Curious to see if the errors are all showing the same address (or if anything changes).

from amplify-js.

seokjeatuiti avatar seokjeatuiti commented on June 12, 2024

@cwomack, Every time I started a new test, I deleted all endpoints using cli to ensure a clean experiment. Of course, since the token address newly created on the device was used during the Firebase Console test, it is unlikely that the token address in the two environments changed or was altered before or after the test.

The gist of what I posted was that the endpoint would be deleted after sending 1-2 messages, and that PERMANENT_FAILURE would be displayed when looking up the endpoint information through cli. It's not a problem with the token address. Fortunately, nothing special has happened since adding Analytics.disable() (Please refer to the above).

In my opinion, this problem appears to have been caused by anomalous use of the Analytics module that does not match the version. I don't think we need to spend any more time on this issue. Therefore, I will close the ticket. Anyway, thank you.

from amplify-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.