Skip to content

Commit

Permalink
Remove authorization request for notifications from app app delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
josh- committed May 27, 2024
1 parent 0b4b980 commit a3db412
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/expo-plugins/withPushNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,15 @@ import {
} from '@expo/config-plugins';
import type { IntercomPluginProps } from './@types';
import {
addObjcImports,
findObjcFunctionCodeBlock,
insertContentsInsideObjcFunctionBlock,
} from '@expo/config-plugins/build/ios/codeMod';

const appDelegate: ConfigPlugin<IntercomPluginProps> = (_config) =>
withAppDelegate(_config, (config) => {
const pushCode = `
// START INTERCOM PUSH
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
completionHandler:^(BOOL granted, NSError *_Nullable error) {
}];
[[UIApplication sharedApplication] registerForRemoteNotifications];
// END INTERCOM PUSH
`;

const setDeviceTokenCode = '[IntercomModule setDeviceToken:deviceToken];';

let stringContents = config.modResults.contents;
stringContents = addObjcImports(stringContents, [
'<UserNotifications/UserNotifications.h>',
]);

if (!stringContents.includes(pushCode.trim())) {
stringContents = insertContentsInsideObjcFunctionBlock(
stringContents,
'application didFinishLaunchingWithOptions:',
pushCode,
{ position: 'tailBeforeLastReturn' }
);
}

const didRegisterBlock = findObjcFunctionCodeBlock(
stringContents,
Expand Down

0 comments on commit a3db412

Please sign in to comment.