【问题标题】:Implementation dynamic links plugin in ionic 1 app unable to functionionic 1 应用程序中的实现动态链接插件无法运行
【发布时间】:2020-11-23 13:09:34
【问题描述】:

我正在尝试在我的 ionic 1 应用程序中使用 dynamic links cordova plugin,我按照此处描述的步骤设置插件 ionic documentation on plugin 但是,我无法使链接生成正常工作,我正在使用以下代码创建并将链接分配给变量

  scope.button = function () {

      cordova.plugins.firebase.dynamiclinks.createDynamicLink({
        link: "https://google.com"
      }).then(function (url) {
        console.log("Dynamic link was created:", url);
        var someVar = url;
      });
    };

之后,我尝试在点击时显示变量,在这里我希望点击该项目后,<span> 中会显示一个链接

<a menu-close class="item sideMenuItem" href="#" ng-click="button()">
                    <i class="icon ion-thumbsup"></i>
                    <span>{{ someVar }}</span>
</a>

但是,它只是没有显示出来

在屏幕截图中,我按下标有“按此处生成”的按钮来调用生成动态链接功能,并希望在下面的span 中看到结果(链接本身),并标有“动态链接在这里”。

{
    "name": "chaishen2",
    "version": "1.1.1",
    "description": "Chaishen2: An Ionic project",
    "dependencies": {
        "@angular/animations": "^5.2.8",
        "bower": "^1.8.8",
        "cordova-admob-sdk": "^0.24.1",
        "cordova-android": "8.1.0",
        "cordova-browser": "^6.0.0",
        "cordova-plugin-admob-free": "^0.27.0",
        "cordova-plugin-androidx": "^2.0.0",
        "cordova-plugin-androidx-adapter": "^1.1.1",
        "cordova-plugin-console": "^1.1.0",
        "cordova-plugin-device": "^1.1.7",
        "cordova-plugin-enable-multidex": "^0.2.0",
        "cordova-plugin-facebook": "^0.2.2",
        "cordova-plugin-firebase-analytics": "^4.3.0",
        "cordova-plugin-firebase-dynamiclinks": "^4.4.0",
        "cordova-plugin-firebasex": "^9.1.2-cli",
        "cordova-plugin-inappbrowser": "^1.7.2",
        "cordova-plugin-splashscreen": "^4.1.0",
        "cordova-plugin-whitelist": "^1.3.4",
        "cordova-plugin-x-toast": "^2.7.2",
        "cordova-promise-polyfill": "0.0.2",
        "cordova-support-android-plugin": "^1.0.2",
        "cordova-support-google-services": "1.4.0",
        "gulp": "^3.5.6",
        "gulp-concat": "^2.2.0",
        "gulp-minify-css": "^0.3.0",
        "gulp-rename": "^1.2.0",
        "gulp-sass": "^2.0.4",
        "ionic-plugin-keyboard": "^2.2.1",
        "ng-cordova-oauth": "^0.3.0",
        "shelljs": "^0.8.3"
    },
    "platforms": [
        "android"
    ],
    "cordova": {
        "platforms": [
            "browser",
            "android"
        ],
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-facebook": {
                "FACEBOOK_DISPLAY_NAME": "VIndex Stock Screener",
                "FACEBOOK_APP_ID": "252597731903503"
            },
            "cordova-plugin-inappbrowser": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-x-toast": {},
            "cordova-plugin-admob-free": {
                "ADMOB_APP_ID": "ca-app-pub-6419100469604124~7181940500"
            },
            "cordova-support-google-services": {},
            "cordova-plugin-firebasex": {
                "FIREBASE_ANALYTICS_COLLECTION_ENABLED": "true",
                "FIREBASE_PERFORMANCE_COLLECTION_ENABLED": "true",
                "FIREBASE_CRASHLYTICS_COLLECTION_ENABLED": "true"
            },
            "cordova-plugin-enable-multidex": {},
            "cordova-plugin-firebase-dynamiclinks": {
                "PAGE_LINK_DOMAIN": "vindexscreener.page.link",
                "FIREBASE_DYNAMIC_LINKS_VERSION": "19.1.+"
            }
        }
    },
    "devDependencies": {
        "@ionic/v1-toolkit": "2.0.17",
        "ionic": "3.9.1"
    }
}

我的package.json

【问题讨论】:

    标签: angularjs firebase cordova ionic-framework firebase-dynamic-links


    【解决方案1】:

    如果 Typescript 尝试:

    export class Test {
    someVar:any;
    constructor(){}
    scope.button = function () {
    
          cordova.plugins.firebase.dynamiclinks.createDynamicLink({
            link: "https://google.com"
          }).then(function (url) {
            console.log("Dynamic link was created:", url);
            this.someVar = url;
          });
        };
    }
    
    <a menu-close class="item sideMenuItem" href="#" ng-click="button()">
                        <i class="icon ion-thumbsup"></i>
                        <span>{{ someVar }}</span>
    </a>
    

    如果 Javascript 尝试:

    .controller('SomePageCtrl', function($scope) {
      $scope.someVar="";
      $scope.button = function () {
          cordova.plugins.firebase.dynamiclinks.createDynamicLink({
            link: "https://google.com"
          }).then(function (url) {
            console.log("Dynamic link was created:", url);
            $scope.someVar = url;
          });
        };
    })
    

    【讨论】:

    • 它是javascript,我相信在这种情况下定义一个类型不会有帮助
    • 我尝试了提供的解决方案,但它仍然无法按预期工作,因为我提到没有任何反应,就像函数根本没有做任何事情一样
    猜你喜欢
    • 2021-11-11
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 1970-01-01
    • 2019-02-07
    • 1970-01-01
    相关资源
    最近更新 更多