parse-community / Parse-SDK-Flutter

The Dart/Flutter SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
575 stars 190 forks source link

Configuring android app for parse push notifications #941

Open cool2apps opened 1 year ago

cool2apps commented 1 year ago

New Issue Checklist

Issue Description

When configuring android app for parse push notification as described in this document: https://docs.parseplatform.org/parse-server/guide/#android-apps If I add this code to AndroidManifest.xml, app will crash if app receives an FCM message.

       <service
           android:name="com.parse.fcm.ParseFirebaseMessagingService"
           android:exported="false">
           <intent-filter>
               <action android:name="com.google.firebase.MESSAGING_EVENT"/>
           </intent-filter>
       </service>

Steps to reproduce

Actual Outcome

If I add that code to AndroidManifest.xml, app will crash if app receives an FCM message.

Expected Outcome

So I removed that code from AndroidManifest.xml, and tried again. This time app does not crash, if app receives an FCM message and looks like app is working fine without this code. No problem I faced by removing that code.

So what my app is missing by removing that code? Or documentation needs to be updated?

Environment

Parse Flutter SDK

Server

Logs

E/AndroidRuntime(32221): FATAL EXCEPTION: Firebase-Messaging-Intent-Handle
E/AndroidRuntime(32221): Process: com.company.appid, PID: 32221
E/AndroidRuntime(32221): java.lang.NullPointerException
E/AndroidRuntime(32221):    at com.parse.PushRouter.getInstance(Unknown Source:15)
E/AndroidRuntime(32221):    at com.parse.fcm.ParseFirebaseMessagingService.onMessageReceived(Unknown Source:89)
E/AndroidRuntime(32221):    at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(Unknown Source:66)
E/AndroidRuntime(32221):    at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(Unknown Source:119)
E/AndroidRuntime(32221):    at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(Unknown Source:12)
E/AndroidRuntime(32221):    at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(Unknown Source:66)
E/AndroidRuntime(32221):    at m6.g.lambda$processIntent$0(Unknown Source:1)
E/AndroidRuntime(32221):    at m6.g.b(Unknown Source:0)
E/AndroidRuntime(32221):    at m6.f.run(Unknown Source:6)
E/AndroidRuntime(32221):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/AndroidRuntime(32221):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/AndroidRuntime(32221):    at l4.c.run(Unknown Source:6)
E/AndroidRuntime(32221):    at java.lang.Thread.run(Thread.java:1012)
W/FlutterJNI(  897): FlutterJNI.loadLibrary called more than once
W/FlutterJNI(  897): FlutterJNI.init called more than once
parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

cool2apps commented 1 year ago

PS: I needed to add android:exported="false" to be able to compile for projects targeting android SDK 32 or newer. Maybe crash occurs because of that. But I can't compile, if I don't add "exported" part. I need to change targetSdkVersion to 30 in order to compile without android:exported="false". But target SDK 30 is too low to publish an app to Play Store.