mirror of
https://github.com/selfxyz/self.git
synced 2026-02-21 03:00:36 -05:00
* add push notification feature * merge new app impl * change dsc key * import * reverse mock dsc * worked in the ios * checked in android * update url and delete console * delete small changes * lint * add yarn.lock * fix warning message * add mock notification service for test code * fix path for the mock implementation * add mock deeplink to the test code * nice notificationServiceMock.js * delete unused firebase related implementation * fix wording and UI related to notification service * hotfix on mockdatascreen --------- Co-authored-by: turnoffthiscomputer <colin.remi07@gmail.com>
43 lines
1.4 KiB
Objective-C
43 lines
1.4 KiB
Objective-C
#import "NotificationService.h"
|
|
#import <Firebase.h>
|
|
|
|
@interface NotificationService ()
|
|
|
|
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
|
|
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
|
|
|
|
@end
|
|
|
|
@implementation NotificationService
|
|
|
|
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
|
|
self.contentHandler = contentHandler;
|
|
self.bestAttemptContent = [request.content mutableCopy];
|
|
|
|
// Configure Firebase if needed
|
|
if (![FIRApp defaultApp]) {
|
|
[FIRApp configure];
|
|
}
|
|
|
|
// Get the message ID
|
|
NSDictionary *userInfo = request.content.userInfo;
|
|
NSString *messageID = userInfo[@"gcm.message_id"];
|
|
if (messageID) {
|
|
[[FIRMessaging messaging] appDidReceiveMessage:userInfo];
|
|
}
|
|
|
|
// Modify the notification content here...
|
|
self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]", self.bestAttemptContent.title];
|
|
|
|
// Always call the content handler with the modified content
|
|
self.contentHandler(self.bestAttemptContent);
|
|
}
|
|
|
|
- (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
|