This commit is contained in:
2025-10-23 16:04:56 +08:00
parent 28ff2b0264
commit e23ef2f814
2 changed files with 21 additions and 3 deletions

View File

@@ -172,6 +172,18 @@
}]; }];
NSLog(@"APNSToken = %@",[FIRMessaging messaging].APNSToken); NSLog(@"APNSToken = %@",[FIRMessaging messaging].APNSToken);
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
if (error) {
NSLog(@"FCM Token 生成失败:%@", error.localizedDescription);
//
// - "Unable to resolve host" Firebase
// - "Invalid project number"GoogleService-Info.plist
} else {
NSLog(@"FCM Token%@", token);
// Token Firebase Token
}
}];
} }
} }
@@ -180,6 +192,11 @@
return UIInterfaceOrientationMaskAll; return UIInterfaceOrientationMaskAll;
} }
//
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"推送注册失败:%@", error.localizedDescription);
}
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken - (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken
{ {
NSLog(@"FCM registration token: %@", fcmToken); NSLog(@"FCM registration token: %@", fcmToken);
@@ -210,6 +227,8 @@
-(void)processWithNoti:(NSDictionary *)userInfo -(void)processWithNoti:(NSDictionary *)userInfo
{ {
NSLog(@"Received the push notification");
NSString *message = [userInfo objectForKey:@"message"]; NSString *message = [userInfo objectForKey:@"message"];
NSData *jsonData = [message dataUsingEncoding:NSUTF8StringEncoding]; NSData *jsonData = [message dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *messageNotiDic = nil; NSDictionary *messageNotiDic = nil;

View File

@@ -42,7 +42,7 @@
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].windows.lastObject.windowScene.statusBarManager; UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].windows.lastObject.windowScene.statusBarManager;
_webView.frame = CGRectMake(0, statusBarManager.statusBarFrame.size.height, self.view.bounds.size.width, self.view.bounds.size.height-self.view.safeAreaInsets.bottom); _webView.frame = CGRectMake(0, statusBarManager.statusBarFrame.size.height, self.view.bounds.size.width, self.view.bounds.size.height-self.view.safeAreaInsets.bottom-statusBarManager.statusBarFrame.size.height);
} }
- (void)viewDidLoad { - (void)viewDidLoad {
@@ -54,11 +54,10 @@
wkWebConfig.preferences.javaScriptCanOpenWindowsAutomatically = YES; wkWebConfig.preferences.javaScriptCanOpenWindowsAutomatically = YES;
_wkUController = [[WKUserContentController alloc] init]; _wkUController = [[WKUserContentController alloc] init];
wkWebConfig.userContentController = _wkUController; wkWebConfig.userContentController = _wkUController;
UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].windows.lastObject.windowScene.statusBarManager; UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].windows.lastObject.windowScene.statusBarManager;
_webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, statusBarManager.statusBarFrame.size.height, self.view.bounds.size.width, self.view.bounds.size.height-self.view.safeAreaInsets.bottom) configuration:wkWebConfig]; _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, statusBarManager.statusBarFrame.size.height, self.view.bounds.size.width, self.view.bounds.size.height-self.view.safeAreaInsets.bottom-statusBarManager.statusBarFrame.size.height) configuration:wkWebConfig];
_webView.UIDelegate = self; _webView.UIDelegate = self;
_webView.navigationDelegate = self; _webView.navigationDelegate = self;
[self.view addSubview:_webView]; [self.view addSubview:_webView];