Skip to content

Commit

Permalink
feat: added setting notification center delegate as configurable prop…
Browse files Browse the repository at this point in the history
…erty (#92)
  • Loading branch information
ami-aman authored Jul 13, 2023
1 parent 3423dcc commit 89ff34e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/helpers/constants/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `

export const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
// Register for push notifications
[pnHandlerObj registerPushNotification:self];
[pnHandlerObj registerPushNotification];
`;

export const CIO_CONFIGURECIOSDKUSERNOTIFICATIONCENTER_SNIPPET = `
Expand All @@ -75,11 +75,10 @@ export const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
}`;
export const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `
@objc(registerPushNotification:)
public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
@objc(registerPushNotification)
public func registerPushNotification() {
let center = UNUserNotificationCenter.current()
center.delegate = notificationDelegate
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
if error == nil{
DispatchQueue.main.async {
Expand Down
7 changes: 6 additions & 1 deletion src/ios/withAppDelegateModifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ export const withAppDelegateModifications: ConfigPlugin<
) {
stringContents = addNotificationConfiguration(stringContents);
}
stringContents = addUserNotificationCenterConfiguration(stringContents);
if (
props.handleNotificationSetup !== undefined &&
props.handleNotificationSetup === false
) {
stringContents = addUserNotificationCenterConfiguration(stringContents);
}
stringContents = addAdditionalMethodsForPushNotifications(stringContents);
stringContents =
addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
Expand Down
1 change: 1 addition & 0 deletions src/types/cio-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type CustomerIOPluginOptionsIOS = {
appleTeamId?: string;
appName?: string;
disableNotificationRegistration?: boolean;
handleNotificationSetup?:boolean;
useFrameworks?: 'static' | 'dynamic';
pushNotification?: {
useRichPush: boolean;
Expand Down

0 comments on commit 89ff34e

Please sign in to comment.