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

unity ios custom image via firebase cloud messages #13948

Closed
jedai7 opened this issue Oct 22, 2024 · 4 comments
Closed

unity ios custom image via firebase cloud messages #13948

jedai7 opened this issue Oct 22, 2024 · 4 comments
Assignees

Comments

@jedai7
Copy link

jedai7 commented Oct 22, 2024

Description

I have android and ios build from unity 2021.3.24. And i want to send push notification with image. In Android it works fine
image
but on ios its dont work. Image missing
image
Original thread created at unity repository firebase/firebase-unity-sdk#1123
image

Reproducing the issue

No response

Firebase SDK Version

10.28.1

Xcode Version

16.0

Installation Method

Swift Package Manager

Firebase Product(s)

Crashlytics, In-App Messaging, Messaging, Remote Config

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@rizafran
Copy link
Contributor

Hi @jedai7, we're unable to reproduce the issue. May I know if you have added the notification service extension in your app?

@jedai7
Copy link
Author

jedai7 commented Nov 5, 2024

Hi @rizafran sorry for long pause. I created
NotificationService.h with code
`//
// NotificationService.h
// NotificationExtention
//
// Created by n1090 on 11.10.2024.
//

#import <UserNotifications/UserNotifications.h>

@interface NotificationService : UNNotificationServiceExtension

@EnD
`

I created NotificationService.m
`//
// NotificationService.m
// NotificationExtention
//
// Created by n1090 on 11.10.2024.
//

#import "NotificationService.h"
@import FirebaseMessaging;

@interface NotificationService ()
@Property(nonatomic) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@Property(nonatomic) UNMutableNotificationContent *bestAttemptContent;
@EnD

@implementation NotificationService

  • (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

    // Modify the notification content here as you wish
    self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]",
    self.bestAttemptContent.title];

    // Call FIRMessaging extension helper API.
    [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent
    withContentHandler:contentHandler];
    }

  • (void)serviceExtensionTimeWillExpire {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    self.contentHandler(self.bestAttemptContent);
    }

@EnD
`

Both file put in Assets/Plugins/iOS in unity project and made build. Trying send messages with icon and result the same

@rizafran
Copy link
Contributor

Sorry for the late revert, @jedai7. As discussed with the team, this seems to be a Unity-related issue since it's not reproducible in native iOS. With this, the original issue you filed in Unity SDK repo will be reopened to investigate. Thanks.

@firebase firebase locked and limited conversation to collaborators Dec 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants