当前位置: 首页 > 软件库 > 手机/移动开发 > >

tns-urihandler

授权协议 MIT License
开发语言 JavaScript TypeScript
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 单于季
操作系统 iOS
开源组织
适用人群 未知
 软件概览

tns-urihandler

A NativeScript Module for inner-app communication URI handling

How to custom scheme in NativeScript Projects

Android
Add following code to your AndroidManifest.xml, where you can find through /app/App_Resources/Android/AndroidManifest.xml

<activity android:launchMode="singleTop">

    <!-- Copy from here -->
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="yourscheme" />
    </intent-filter>
    <!-- Copy end here -->

</activity>

NOTE: the attribute android:launchMode="singleTop" prevent OS start multiple activities.

iOS
Add following code to your Info.plist, where you can find it in /app/App_Resources/iOS/Info.plist

<dict>
    <!-- Copy from here -->
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>your.app.id</string>
        </dict>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>yourscheme</string>
            </array>
        </dict>
    </array>
    <!-- Copy end here -->
</dict>

NOTE: After modified AndroidManifest.xml or Info.plist, please remove the entire platform and re-add the platform. This is also recommended by official document.

How to install Plugin?

Run command

    tns plugin add tns-urihandler

or

    tns plugin add tns-urihandler-1.0.0.tgz

How to use Plugin?

imcoming URI: myapp://Jacky:Passw0rd@home/path/to/my/page?from=anotherApp#fragment

import { URIHandler } from 'tns-urihandler';

    export class MyApp{
        foo(): void{
            let uriHandler = new URIHandler();
            console.log(uriHandler.getURI()); // myapp://Jacky:Passw0rd@home/path/to/my/page?from=anotherApp#fragment
        }
    }

APIs

uriHandler.getURI();            // myapp://Jacky:Passw0rd@home/path/to/my/page?from=anotherApp#fragment
    uriHandler.getHost();           // home
    uriHandler.getFragment();       // fragment
    uriHandler.getScheme();         // myapp
    uriHandler.getQuery();          // from=anotherApp
    uriHandler.getPath();           // path/to/my/page
    uriHandler.getUser();           // Jacky (if there's any Username)
    uriHandler.getPassword();       // Passw0rd (if there's any Password)

    // experimental function, returns object
    uriHandler.search();            // { form: 'antherApp' }

Thanks

I would like to thank hypery2k's nativescript-urlhandler.My inspiration comes from his great work.

 相关资料
  • tns

    tns为 thrift rpc 分布式组件,实现 rpc 的高可靠、负载均衡、水平动态可扩展等,工具提供完整的命令行管理方式。

  • Tns Ng Angular CLI for Nativescript. Generates component for Nativescript Angular projects Table of Contents Installation Usage Generating Components and Services Contributing Installation npm install

  • lsnrctl启动侦听器时遇到以下错误。 错误侦听:(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))TNS-12542: TNS:地址已在使用TNS-12560: TNS:协议适配器错误TNS-00512:地址已在使用Linux错误: 98:地址已在使用 listener.ora的内容如下。NSMS=(DESCRIPTION_LIST=(DESCRIPTION=

  • This repository is deprecated in favor of NativeScirpt/NativeScript/tns-core-modules-widgets. NativeScript Core Modules Widgets This repository contains the source code of the tns-core-modules-widgets

  • 我收到以下错误消息 JAVAsql。SQLException:Listener拒绝了连接,出现以下错误:ORA-12505,TNS:Listener当前不知道连接描述符中给出的SID 原因:甲骨文。网纳什。NetException:侦听器拒绝连接,出现以下错误:ORA-12505,TNS:侦听器当前不知道连接描述符中给出的SID 请帮我这个...

  • 问题内容: 在我的NativeScript项目中,我想包含RecyclerViewAndroid支持库中的内容。我将依赖项包括在: 从git issue#2295和其他相关问题中,我读到tns-platform-declarations可以提供本机android / ios库的定义文件的内容。所以我安装了它们并遵循了tns平台声明文档 我想编译以下示例代码段: 声明var android以上类似内