修改
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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];
|
||||||
|
|||||||
Reference in New Issue
Block a user