Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending push notifications not possible in native mode #427

Open
andlinger opened this issue May 8, 2023 · 2 comments
Open

Sending push notifications not possible in native mode #427

andlinger opened this issue May 8, 2023 · 2 comments

Comments

@andlinger
Copy link

It's not possible to send push notifications with FirebaseMessaging if extension is running in native mode.

Following code works in JAR but not in native:

var messaging = FirebaseMessaging.getInstance(firebaseApp);


var notification = Notification.builder()
        .setTitle("Title")
        .setBody("Body")
        .build();

var message = MulticastMessage.builder()
        .setNotification(notification)
        .addAllTokens(List.of("DEVICE_TOKEN"))
        .build();

try {
    var response = messaging.sendMulticast(message);
} catch (FirebaseMessagingException e) {
    throw new RuntimeException(e);
}

The request runs properly, but if you look at the response, you can see that for each device token the following error occurs:

com.google.firebase.messaging.FirebaseMessagingException: Recipient of the message is not set.
        at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingBatchCallback.onFailure(FirebaseMessagingClientImpl.java:259)
        at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingBatchCallback.onFailure(FirebaseMessagingClientImpl.java:243)
        at com.google.api.client.googleapis.batch.BatchUnparsedResponse.parseAndCallback(BatchUnparsedResponse.java:209)
        at com.google.api.client.googleapis.batch.BatchUnparsedResponse.parseNextResponse(BatchUnparsedResponse.java:149)
        at com.google.api.client.googleapis.batch.BatchRequest.execute(BatchRequest.java:269)
        at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendBatchRequest(FirebaseMessagingClientImpl.java:138)
        at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendAll(FirebaseMessagingClientImpl.java:118)
        at com.google.firebase.messaging.FirebaseMessaging$2.execute(FirebaseMessaging.java:295)
        at com.google.firebase.messaging.FirebaseMessaging$2.execute(FirebaseMessaging.java:292)
        at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
        at [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at [email protected]/java.lang.Thread.run(Thread.java:833)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
@andlinger
Copy link
Author

andlinger commented May 8, 2023

Got it to work with following reflection-config.json file:

[
  {
    "name" : "com.google.firebase.messaging.Message",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true,
    "allDeclaredFields" : true,
    "allPublicFields" : true
  },
  {
    "name" : "com.google.firebase.messaging.internal.MessagingServiceResponse",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true,
    "allDeclaredFields" : true,
    "allPublicFields" : true
  }
]

@loicmathieu
Copy link
Collaborator

Firebase messaging is not supported for the moment.

If you have GraalVM native image reflection configuration for it, the best is to open an issue upstream (should b https://github.com/firebase/firebase-admin-java) as Google Cloud library authors now include GraalVM native image support directly inside their libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants