• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    해결됨

remote push notification이 포그라운드에서 팝업되지 않아요

23.06.26 22:37 작성 23.06.27 10:08 수정 조회수 552

0

핸드폰 상단바에서 알림 표시만 되고 알림 팝업은 되지 않습니다.

localNotification을 활용해서 팝업시켜 봤지만 그렇게 될 경우 onNotification과 함께 중복된 알람 2개가 동시에 옵니다.그리고 상단바를 열어서 localNotification으로 온 알람을 press하게 되면 데이터가 빈 오브젝트로 넘어와서 Screen Navigate를 하지 못합니다.

(onNotification로 발생하는 알림에서만 데이터를 활용할 수 있는 상황입니다)

결론은 onNotification로 온 알림이 팝업되어서 press를 하면 해당 화면을 이동시키는게 최종 목적이고

현재 포그라운드에서 알림 팝업이 안되는 이슈를 해결하고 싶습니다..계속 찾아봐도 답을 못 찾겠어서 질문 남깁니다!

// AndroidManifest.xml
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground" android:value="true"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="true">
   <intent-filter>
      <action android:name="android.intent.action.BOOT_COMPLETED" />
      <action android:name="android.intent.action.QUICKBOOT_POWERON" />
      <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
   </intent-filter>
</receiver>
<service
   android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
   android:exported="false" >
   <intent-filter>
      <action android:name="com.google.firebase.MESSAGING_EVENT" />
   </intent-filter>
</service>

// App.tsx
PushNotification.configure({
     onNotification: function (notification: any) {
         PushNotification.localNotification({
             message: notification.message,
             title: notification.title,
             channelId: 'channel_general',
         })
    }
})

PushNotification.createChannel(
    {
        channelId: 'channel_general',
        channelName: '앱', 
    },
    (created: boolean) => console.log(`createChannel returned '${created}'`),
);

답변 1

답변을 작성해보세요.

0

팝업이라는 게 뭔지 이해가 잘 안 되는데요. 다른 앱중에 팝업이 뜨는 예시가 있을까요??

Oim님의 프로필

Oim

질문자

2023.06.27

image포그라운드에서 상단에 뜨는걸 말한건데 팝업이라는 표현이 맞는지 모르겠네요.

이외에도 인스타에서도 포그라운드 상태에서 상단에 알림이 뜨는걸로 알고있습니다.

저도 이렇게 띄우고 싶은데 localNotification으로는 data: {} 빈 오브젝트로 넘어와서 활용하기 어려울거 같고

onNotification으로 발생하는 알림은 data가 정상적으로 넘어와서 onNotification으로 오는 알림을 팝업?시키고 싶습니다

Oim님의 프로필

Oim

질문자

2023.06.27

엇 됩니다! 감사합니다 :)