SEL-472: Enable production push notifications (#703)

* chore: leave sandbox apns token comment

* tweak entitlement

* coderabbit ai feedback

* firebase tweaks
This commit is contained in:
Justin Hernandez
2025-06-29 22:58:46 -07:00
committed by GitHub
parent 180aeeca71
commit 77c7b82293
3 changed files with 34 additions and 16 deletions

6
app/firebase.json Normal file
View File

@@ -0,0 +1,6 @@
{
"react-native": {
"messaging_auto_init_enabled": true,
"messaging_ios_auto_register_for_remote_messages": true
}
}

View File

@@ -15,21 +15,28 @@
{
[FIRApp configure];
// TODO: Uncomment this after the APN has been configured
// if ([UNUserNotificationCenter class] != nil) {
// UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
// center.delegate = self;
if ([UNUserNotificationCenter class] != nil) {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
// // Request permission for notifications
// [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)
// completionHandler:^(BOOL granted, NSError * _Nullable error) {
// if (granted) {
// dispatch_async(dispatch_get_main_queue(), ^{
// [[UIApplication sharedApplication] registerForRemoteNotifications];
// });
// }
// }];
// }
// Request permission for notifications
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to request notification authorization: %@", error.localizedDescription);
return;
}
if (granted) {
NSLog(@"Notification authorization granted");
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
} else {
NSLog(@"Notification authorization denied by user");
}
}];
}
self.moduleName = @"OpenPassport";
self.initialProps = @{};
@@ -65,7 +72,12 @@ continueUserActivity:(NSUserActivity *)userActivity
{
NSString *token = [self stringFromDeviceToken:deviceToken];
NSLog(@"APNs device token: %@", token);
#ifdef DEBUG
[[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRMessagingAPNSTokenTypeSandbox];
#else
[[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRMessagingAPNSTokenTypeProd];
#endif
}
// Handle device token registration errors

View File

@@ -2,8 +2,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>aps-environment</key>
<string>development</string>
<key>aps-environment</key>
<string>production</string>
<key>com.apple.developer.associated-appclip-app-identifiers</key>
<array>
<string>5B29R5LYHQ.com.warroom.proofofpassport.Clip</string>