mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 06:38:09 -05:00
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:
6
app/firebase.json
Normal file
6
app/firebase.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"react-native": {
|
||||
"messaging_auto_init_enabled": true,
|
||||
"messaging_ios_auto_register_for_remote_messages": true
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user