-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[issue-1048] Integrate Onesignal for push notification
- Loading branch information
1 parent
0d112b0
commit 5938af2
Showing
17 changed files
with
490 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "569870677705", | ||
"project_id": "subwallet-app", | ||
"storage_bucket": "subwallet-app.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:569870677705:android:cbc031f789e9677e38ff18", | ||
"android_client_info": { | ||
"package_name": "app.subwallet.mobile" | ||
} | ||
}, | ||
"oauth_client": [], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyBePKienltD3ss-ifbPEuoHOQA-OSigkVY" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.usernotifications.service</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>NotificationService</string> | ||
</dict> | ||
</dict> | ||
</plist> |
12 changes: 12 additions & 0 deletions
12
ios/OneSignalNotificationServiceExtension/NotificationService.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// NotificationService.h | ||
// OneSignalNotificationServiceExtension | ||
// | ||
// Created by Thức Nguyễn Duy on 29/09/2023. | ||
// | ||
|
||
#import <UserNotifications/UserNotifications.h> | ||
|
||
@interface NotificationService : UNNotificationServiceExtension | ||
|
||
@end |
40 changes: 40 additions & 0 deletions
40
ios/OneSignalNotificationServiceExtension/NotificationService.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#import <OneSignalExtension/OneSignalExtension.h> | ||
|
||
#import "NotificationService.h" | ||
|
||
@interface NotificationService () | ||
|
||
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); | ||
@property (nonatomic, strong) UNNotificationRequest *receivedRequest; | ||
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent; | ||
|
||
@end | ||
|
||
@implementation NotificationService | ||
|
||
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { | ||
self.receivedRequest = request; | ||
self.contentHandler = contentHandler; | ||
self.bestAttemptContent = [request.content mutableCopy]; | ||
|
||
/* DEBUGGING: Uncomment the 2 lines below and comment out the one above to ensure this extension is executing | ||
Note, this extension only runs when mutable-content is set | ||
Setting an attachment or action buttons automatically adds this */ | ||
// NSLog(@"Running NotificationServiceExtension"); | ||
// self.bestAttemptContent.body = [@"[Modified] " stringByAppendingString:self.bestAttemptContent.body]; | ||
|
||
[OneSignalExtension didReceiveNotificationExtensionRequest:self.receivedRequest | ||
withMutableNotificationContent:self.bestAttemptContent | ||
withContentHandler:self.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. | ||
|
||
[OneSignalExtension serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent]; | ||
|
||
self.contentHandler(self.bestAttemptContent); | ||
} | ||
|
||
@end |
10 changes: 10 additions & 0 deletions
10
ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.application-groups</key> | ||
<array> | ||
<string>group.app.subwallet.mobile.onesignal</string> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.