国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

iOS 鏈接

2019-08-14 14:23 更新

LinkingIOS 給你提供了一個通用接口,用來連接接收和發(fā)送應用程序的鏈接。

基本用法

處理深度鏈接

如果你的應用程序是從一個外部鏈接啟動的,并且這個外部鏈接是注冊到你的應用程序里的,那么你就可以利用任意你想要的組件去訪問并且處理它

    componentDidMount() {     var url = LinkingIOS.popInitialURL();
    }

在你的應用程序運行期間,如果你也想監(jiān)聽傳入應用程序的鏈接,那么你需要將以下幾行添加到你的 *AppDelegate.m

    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {      return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
    }

那么,在你的 React 組件中,你可以監(jiān)聽 LinkingIOS 上的事件,如下所示:

    componentDidMount() {
      LinkingIOS.addEventListener('url', this._handleOpenURL);
    },
    componentWillUnmount() {
      LinkingIOS.removeEventListener('url', this._handleOpenURL);
    },
    _handleOpenURL(event) {
      console.log(event.url);
    }

觸發(fā)應用程序鏈接

為了觸發(fā)一個應用程序的鏈接(瀏覽器,電子郵件,或者自定義模式),你需要調(diào)用

LinkingIOS.openURL(url)

如果你想要檢查一個已經(jīng)安裝的應用程序是否可以提前處理一個給定的鏈接,你可以調(diào)用

    LinkingIOS.canOpenURL(url, (supported) => {      if (!supported) {
        AlertIOS.alert('Can\'t handle url: ' + url);
      } else {
        LinkingIOS.openURL(url);
      }
    });

方法

static addEventListener(type: string, handler: Function)

通過監(jiān)聽 url 事件類型和提供處理程序,將一個處理程序添加到 LinkingIOS changes

static removeEventListener(type: string, handler: Function)

通過傳遞 url 事件類型和處理程序,刪除一個處理程序

static openURL(url: string)

嘗試通過任意已經(jīng)安裝的應用程序打開給定的 url

static canOpenURL(url: string, callback: Function)

決定一個已經(jīng)安裝的應用程序是否可以處理一個給定的 url,該方法中回調(diào)函數(shù)將被調(diào)用,并且僅通過一個 bool supported 的參數(shù)。

static popInitialURL()

如果應用程序啟動是通過一個應用程序鏈接觸發(fā)的,那么它將彈出這個鏈接的 url,否則它將返回 null


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號