Lauch FB messenger in Ionic

Hi all,

I want to launch Facebook Messenger when user click to a button.
I use these code but It said “com.facebook.orca is NOT available”

this.appAvailability.check(app)
.then(
  (yes) => {
    console.log(app + ' is available')
    const browser = this.iab.create(app);
    browser.show();
  },
  (no) => console.log(app + ' is NOT available')
  );

How can I do it ? Please help me.

Thanks

Check what the error from the promise is

this.appAvailability.check(app).then(
	() => {
		console.log(app, "is available");
		
		const browser = this.iab.create(app);
		browser.show();
	},
	err => {
		console.log(app, "is NOT available");
		console.log(err);
	}
);

Thank @mich356c

It has no error from the promise. When I clicked to the button, nothing happen.
. this.iab.create(app); // app : fb-messenger://

Nothing happens? Doesn’t it say either of “is available” or “is not available”? Can you provide some more code of the button and what it’s calling

@mich356c
I think the problem is the function appAvailability, so I remove the code appAvailability.

const browser = this.iab.create(app);
	browser.show();

It open a browser with the url is http://'fb-messenger://

Shouldn’t that say com.facebook.orca? Maybe the issue is that the wrong app id is entered somewhere

I changed the app link to com.facebook.orca, It open the fb messenger now. but It also crash my app :frowning:

Well, progress :joy: Still no errors in the console? Does browser.show() return a Promise which could potentially have an uncaught error?

The error in Android studio :

java.lang.NullPointerException: Attempt to invoke virtual method ‘void org.apache.cordova.inappbrowser.InAppBrowserDialog.show()’ on a null object reference
at org.apache.cordova.inappbrowser.InAppBrowser$2.run(InAppBrowser.java:257)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

It seems that calling show is only needed if you create the instance as hidden, which you did not, so I believe you can scrap the .show()

Did you mean remove the code browser.show(); . I 've removed it. It not crash, but it restart my app and not open fb messenger :smile:

Have a look at this Ionic opening external app :upside_down:

I read the topic you sent before. It does not work.

Thank for your help.