Firebase动态链接在react-native中的iOS上不起作用。

huangapple go评论64阅读模式
英文:

Firebase Dynamic Links is not working for iOS in react-native

问题

我已经为我的React Native应用设置了无密码身份验证,为此需要设置Firebase动态链接,我已成功完成此操作。

并且在Android和iOS两个平台上一切正常运行,但在将我的分支合并到主分支后,iOS上停止工作。
这意味着我收到了用于登录的电子邮件,但该链接无法打开iOS应用程序,但在Android上可以成功工作。

我执行了以下步骤来设置iOS的动态链接:

  1. AppDelegate.m
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@import Firebase;
//Deep Linking RNavigation Docs
#import <React/RCTLinkingManager.h>
//Deep Linking RNavigation Docs

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
 RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                  moduleName:@"realyze"
                                           initialProperties:nil];

 rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
 UIViewController *rootViewController = [UIViewController new];
 rootViewController.view = rootView;
 self.window.rootViewController = rootViewController;
 [self.window makeKeyAndVisible];
 [FIRApp configure];
 return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
 return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
 return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
//Deep Linking RNavigation Docs
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
           options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
 return [RCTLinkingManager application:app openURL:url options:options];
}
//Deep Linking RNavigation Docs

@end
  1. 添加了关联域名功能
    在Xcode和我的Apple开发者帐户中为特定的应用程序

  2. 在Firebase控制台中为appID前缀添加了TeamID。

  3. 添加了这些Firebase授权域名:
    applinks:realyze.page.link
    activitycontinuation:realyze.page.link

  4. 还将域名添加到 entitlements 文件中

  5. app-site-associations-file 也已正确设置

在将我的分支合并之前,这个设置对我有用。

非常感谢您的帮助。

谢谢。

英文:

I have setup Passwordless authentication for my react-native app, for that it required to setup firebase dynamic links which I did successfully.

And everything was working fine on both Platforms Android and iOS, but after I merged my branch with the master, it stopped working on iOS.
Meaning I am receiving the email to SignIn but that link is not opening the iOS app but it is working on Android successfully.

I did the following steps to setup Dynamic Links for iOS:

  1. AppDelegate.m
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@import Firebase;
//Deep Linking RNavigation Docs
#import <React/RCTLinkingManager.h>
//Deep Linking RNavigation Docs

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
 RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                  moduleName:@"realyze"
                                           initialProperties:nil];

 rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
 UIViewController *rootViewController = [UIViewController new];
 rootViewController.view = rootView;
 self.window.rootViewController = rootViewController;
 [self.window makeKeyAndVisible];
 [FIRApp configure];
 return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
 return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
 return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
//Deep Linking RNavigation Docs
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
           options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
 return [RCTLinkingManager application:app openURL:url options:options];
}
//Deep Linking RNavigation Docs

@end
  1. Added Association Domains Capability
    In Xcode and in my Apple Developer Account for the particular App

  2. Added TeamID to Firebase Console for the appID prefix.

  3. Added these Firebase Authorized Domains:
    applinks:realyze.page.link
    activitycontinuation:realyze.page.link

  4. Also added domains to an entitlements file

6.app-site-associations-file is also setup correctly

This setup worked for me before I merged my branch.

Help would be very much appreciated.

Thank you.

答案1

得分: 0

我在我的 AppDelegate.m 文件中添加了以下代码行:

//通用链接

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
 restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
 return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
}

这对我有用,现在我已经将应用程序部署为Beta版。

英文:

I added the following lines of code to my AppDelegate.m:

//Universal Links

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
 restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
 return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
}

This worked for me and I have now deployed the app for Beta

huangapple
  • 本文由 发表于 2020年1月3日 19:50:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/59578134.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定