Skip to content

Sending push notifications not possible in native mode #427

@andlinger

Description

@andlinger

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 java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base@17.0.6/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base@17.0.6/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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    upsteamIssue on an upsteam library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions