napolitano / cordova-plugin-intent

Plugin for apache cordova (Android Only) that allows interaction with the intent.
MIT License
84 stars 88 forks source link

Cannot make the plugin work in Phonegap app #22

Open akadebnath opened 6 years ago

akadebnath commented 6 years ago

Not sure why I am not able to make it work.

Here is what I have done.

Opened PhoneGap desktop app (Windows 10) Created a new Hello World App. Open command prompt, cd to the app directory

phonegap local plugin add https://github.com/napolitano/cordova-plugin-intent

It installed the plug in. In plugins directory I can see this directory:

com.napolitano.cordova.plugin.intent

In config.xml I have:

<plugin name="com.napolitano.cordova.plugin.intent" spec="https://github.com/napolitano/cordova-plugin-intent" />

In AndroidManifest.xml I have:

<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <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="https" />
            </intent-filter>
        </activity>
</application>

So, any link with https schema is giving me option to open my app. This is fine.

In index.html I have:

<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener('deviceReady', function(){
    window.plugins.intent.getCordovaIntent(function (Intent) {
        console.log(Intent);
    }, function () {
        console.log('Error');
    });
});
</script>

In Chrome Console, I am getting this error:

Uncaught TypeError: Cannot read property 'getCordovaIntent' of undefined

So, I think the plug in is not initiated at all. Or it is something else? Whatever it is, I am struggling for two days to make it work. Please let me know what wrong I am doing.