lampaa / com.lampa.startapp

Phonegap plugin for check or launch other application in android device.
MIT License
228 stars 120 forks source link

ionic2 how to import plugin to project? #83

Open wzhua opened 7 years ago

wzhua commented 7 years ago

problem is startApp is undefined. my code :

import {
    Component
} from '@angular/core';
import {
    NavController
} from 'ionic-angular';

declare
var startApp;

@Component({
    selector: 'page-home',
    templateUrl: 'home.html'
})

export class HomePage {

    constructor(public navCtrl: NavController) {
        //console.log(startApp);
    }

    openDemo() {
        alert('xxx');
        startApp.set({
            "action": "ACTION_MAIN",
            "uri": "http://uri.amap.com/marker?position=121.287689,31.234527&name=park&src=mypage&coordinate=gaode&callnative=0",
            "intentstart": "startActivity"
        }, {}).start();
    }
}

thank you

wuilmerj24 commented 7 years ago

@wzhua Hi, did you solve it?

pyw-cacphy commented 7 years ago

I also need to know. How to solve it? anyone face the same problem and got the solution?

pavel-kurnosov commented 7 years ago

Just add to your declarations.d.ts file declare var startApp:any; and then all will be fine. This is just compilation error from TS.

DanielnetoDotCom commented 6 years ago

Still a problem here :(

manaswinid14 commented 6 years ago
var sApp = (window as any).startApp.set({
    "package": "io.myapp"
});

sApp.start();

Try this.. It works for me.

MCDevelo commented 6 years ago

Hi lampaa, im using this code, but it doesnt work.

facebookButton(){ this.platform.ready().then(()=>{ let appId = AllSocialApps.Facebook.android.appId; let appStarter = (window).startApp.set({ "application": appId }).start(function (msg) { console.log('starting FB app: ' + msg); }, function (err) { console.log('FB app not installed', err); window.open(AllSocialApps.Facebook.android.urlApp, '_system', 'locations=yes'); }); }); }

And I also try with this one facebookButton(){ this.platform.ready().then(()=>{ let appId = AllSocialApps.Facebook.android.appId; let appStarter = (window as any).startApp.set({ "application": appId }).start(function (msg) { console.log('starting FB app: ' + msg); }, function (err) { console.log('FB app not installed', err); window.open(AllSocialApps.Facebook.android.urlApp, '_system', 'locations=yes'); }); }); }

And then it dosent work, i just take this error Error: Uncaught (en promesa): TypeError: No se puede leer la propiedad 'set' de TypeError indefinido: No se puede leer la propiedad 'set' de undefined en http: // localhost: 8100 / build / main.js: 519: 46 en t.invoke (http: // localhost: 8100 / build / polyfills.js: 3: 14976) en Object.onInvoke (http: // localhost: 8100 / build / vendor.js: 5134: 33) en t.invoke (http: / /localhost:8100/build/polyfills.js:3:14916) en r.run (http: // localhost: 8100 / build / polyfills.js: 3: 10143) en http: // localhost: 8100 / build / polyfills .js: 3: 20242 en t.invokeTask (http: // localhost: 8100 / build / polyfills.js: 3: 15660) en Object.onInvokeTask (http: // localhost: 8100 / build / vendor.js: 5125: 33) en t.invokeTask (http: // localhost: 8100 / build / polyfills.js: 3: 15581) en r.runTask (http: // localhost: 8100 / build / polyfills.js: 3: 10834) en c (http: // localhost: 8100 / build / polyfills.js:3: 19752) en http: // localhost: 8100 / build / polyfills.js: 3: 20273 en t.invokeTask (http: // localhost: 8100 / build / polyfills.js: 3: 15660) en Object.onInvokeTask ( http: // localhost: 8100 / build / vendor.js: 5125: 33) en t.invokeTask (http: // localhost: 8100 / build / polyfills.js: 3: 15581) en r.runTask (http: // localhost: 8100 / build / polyfills.js: 3: 10834) en o (http: // localhost: 8100 / build / polyfills.js: 3: 7894) en e.invokeTask [como invocar] (http: // localhost: 8100 / build / polyfills.js: 3: 16823) en p (http: // localhost: 8100 / build / polyfills.js: 2: 27648) en HTMLImageElement.v (http: // localhost: 8100 / build / polyfills. JS: 2: 27893)invokeTask (http: // localhost: 8100 / build / polyfills.js: 3: 15581) en r.runTask (http: // localhost: 8100 / build / polyfills.js: 3: 10834) en o (http: // localhost: 8100 / build / polyfills.js: 3: 7894) en e.invokeTask [como invocación] (http: // localhost: 8100 / build / polyfills.js: 3: 16823) en p (http: // localhost: 8100 / build / polyfills.js: 2: 27648) en HTMLImageElement.v (http: // localhost: 8100 / build / polyfills.js: 2: 27893)invokeTask (http: // localhost: 8100 / build / polyfills.js: 3: 15581) en r.runTask (http: // localhost: 8100 / build / polyfills.js: 3: 10834) en o (http: // localhost: 8100 / build / polyfills.js: 3: 7894) en e.invokeTask [como invocación] (http: // localhost: 8100 / build / polyfills.js: 3: 16823) en p (http: // localhost: 8100 / build / polyfills.js: 2: 27648) en HTMLImageElement.v (http: // localhost: 8100 / build / polyfills.js: 2: 27893).

Please help me Im using ionic 3..