How to get URL with loadstart event in app browser in ionic 4 for instagram api? - api

I try to get URL with inAppBrowser in ionic 4 for my instagram api. I build PWA and smartphone applications. . Why loadstart event
does not work when I build in PWA ?
I've already tried to get with in app browser plugin for ionic4 and with javascript (window.open() method).
In app Browser work when I build my IOS app.
That doesn't work when I build my PWA app/
//instagram API
let authUrl = `https://www.instagram.com/oauth/authorize/?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=token&scope=public_content`;
//create in app browser
var browser = this.iab.create(authUrl, '_blank');
//test loadstart event
browser.on('loadstart').subscribe(event => {
alert('loadstart');
alert(event.url);
}, err => {
alert("InAppBrowser loadstart Event Error: " + err);
});
//test loadstop event
browser.on('loadstop').subscribe(event => {
alert('loadstop');
alert(event.url);
}, err => {
alert("InAppBrowser loadstop Event Error: " + err);
});
}
PWA output :
loadstop
event.url == ""
IOS output :
loadstart
event.url == url
loadstop
event.url == ""
Thank you :)

inAppBrowser is a cordova plugin it will work fine in android & ios App, but pwa is completely web app it will not support cordova plugin, So it's better to show it in a component it will work fine.

Related

Why is my universal route not working? Or what is it actually doing?

I am setting a universal link with a React Native app. It is routing to my app, but I am not getting the behavior that I expect.
Here is the component piece of my AASA file.
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": ""
},
{
"/": "/oauth*",
"comment": "Redirect URL for OAuth"
}
]
The AASA file is hosted at a url that I own. I have installed the app on my phone, pulled the sysdiagnose file off my device and verified that my app is downloading the AASA file, so the routes should be working on my device.
In my React Native code, I have an event watcher looking at the urls that are being used to open the app. I am using the expo-linking library to log the url and params.
function handleLink(event) {
const data = Linking.parse(event.url);
console.log(data, data);
}
React.useEffect(() => {
Linking.getInitialURL().then((res) => {
console.log(res);
});
const listener = Linking.addEventListener("url", handleLink);
return () => listener.remove();
}, []);
When I route to <url>/oauth in safari, it gives the options to open up my app. When I use the app option the system then routes to my app. The code above then logs out the url and query params from the url that opened the app.
When I try to use the universal link for the actual OAuth redirect (not from Safari), it opens up my app, but no url is logged out from the event, so the event is not being hit at all. Also, it looks like it is opening up some kind of webpage in my app, but the fact is I really don't know what it is doing.
In short, when using my app with another service calling the url, it opens up my app, but I only see a white page and only know I am on my app by looking at the title of the app.
If anyone could give me any direction, I would be really grateful.

How to open URL with scheme intent:// on react native

I have a react native mobile app with a webview. In the webview I added the facebook messenger chat plugin so my users can easily contact us if they need help.
if you ran the website through a mobile browser it works. It redirects you to the official messenger.
But when you ran it through react native webview somehow it says No activity found to handle Intent
here is my code on how i handle the opening of the intent
onShouldStartLoadWithRequest={(request) => {
let url = request.url
if(url.startsWith('intent:')){
Linking.openURL(url).catch(er => {
console.log(er)
alert("Failed to open URL")
});
return false
}else{
return true
}
}}
this will console log
[Error: Could not open URL
'intent://user/107571147455693/?intent_trigger=mme&nav=discover&source=customer_chat_plugin&source_id=1507329&metadata=%7B%22referer_uri%22%3A%22https%3A%5C%2F%5C%2Ffusiontechph.com%5C%2Ff9fe1863270a2%22%7D#Intent;scheme=fb-messenger;package=com.facebook.orca;end':
No Activity found to handle Intent { act=android.intent.action.VIEW
dat=intent://user/107571147455693/?intent_trigger=mme&nav=discover&source=customer_chat_plugin&source_id=1507329&metadata={"referer_uri":"https://fusiontechph.com/f9fe1863270a2"}
flg=0x10000000 }]
I have a workaround that worked for me. Facebook messenger provides a link to your facebook page message. So you can just open that link directly without using the intent scheme of facebook here is the final code
onShouldStartLoadWithRequest={(request) => {
let url = request.url
if(url.startsWith('intent:')){
Linking.openURL('https://m.me/mluc.jsites').catch(e=>{
console.log(e) })
return false
}else{
return true
}
}}

Google Photos API integration in React Native

I am using React native Google Sign in plugin for authenticating the users, to use google photos API. According to the given documentation of the plugin, I did the configurations. It is working fine on the iOS platform but not on the Android platform.
configuring google sign in
configureGoogleSignIn = async () => {
GoogleSignin.configure({
scopes: [
'https://www.googleapis.com/auth/photoslibrary',
'https://www.googleapis.com/auth/photoslibrary.sharing',
],
shouldFetchBasicProfile: true,
iosClientId:
Platform.OS === 'ios'
? 'iOS_PLATFORM_CLIENT_ID'
: 'ANDROID_PLATFORM_CLIENT_ID',
// offlineAccess: true,
});
};
When I use this code and sign in with an iOS device or simulator it is working fine and return the user details with idToken but on the android device, it only returns the user details and idToken as null.
Anybody help me with this

Open Whatsapp from React Native app with Expo

Currently trying to open whatsapp from my React Native app with Expo. I have the code below:
let url = 'whatsapp://app';
Linking.openURL(url).then((data) => {
console.log('WhatsApp Opened');
}).catch((err) => {
console.log(err);
alert('Make sure Whatsapp installed on your device');
});
The error I get is this:
Error: Could not open URL 'whatsapp://app': No Activity found to handle Intent { act=android.intent.action.VIEW dat=whatsapp://app flg=0x10000000 }
However when I change the url to send, it opens whatsapp fine?
whatsapp://send?phone=3464478983
I am trying to only open whatsapp without a send param

Push notification with Appcelerator (ACS) on Android

I'm trying to implement push notification with Appcelerator Cloud Service on Android But I have some issues ... tiapp.xml here :
<sdk-version>2.0.2.GA</sdk-version>
<modules>
<module platform="commonjs" version="2.0.5">ti.cloud</module>
<module platform="android" version="2.0.5">ti.cloudpush</module>
</modules>
Android runtime v8 and ti.cloudpush included, here is my app.js file
var win = Ti.UI.createWindow({
backgroundColor:'#ccc',
title:'Android Cloud Push Notification'
})
var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.focusAppOnPush = false;
var deviceToken;
var Cloud = require('ti.cloud');
Cloud.debug = true;
var submit = Ti.UI.createButton({
title : 'Register For Push Notification',
color:'#000',
height : 53,
width : 200,
top : 100,
});
win.add(submit);
submit.addEventListener('click', function(e) {
CloudPush.retrieveDeviceToken({
success: function deviceTokenSuccess(e) {
alert('Device Token: ' + e.deviceToken);
deviceToken = e.deviceToken
loginDefault();
},
error: function deviceTokenError(e) {
alert('Failed to register for push! ' + e.error);
}
});
});
function defaultSubscribe(){
Cloud.PushNotifications.subscribe({
channel: 'chanel',
device_token: deviceToken,
type: 'android'
}, function (e){
if (e.success) {
alert('Subscribed for Push Notification!');
}else{
alert('Error:' +((e.error && e.message) || JSON.stringify(e)));
}
});
}
function loginDefault(e){
//Create a Default User in Cloud Console, and login
Cloud.Users.login({
login: 'android',
password: 'android'
}, function (e) {
if (e.success) {
alert("login success");
defaultSubscribe();
} else {
alert('Error: ' +((e.error && e.message) || JSON.stringify(e)));
}
});
}
CloudPush.addEventListener('callback', function (evt) {
//alert(evt);
alert(evt.payload);
});
CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
//Ti.API.info('Tray Click Launched App (app was not running)');
alert('Tray Click Launched App (app was not running');
});
CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
//Ti.API.info('Tray Click Focused App (app was already running)');
alert('Tray Click Focused App (app was already running)');
});
win.open();
I had the user android / android in the Appcelerator cloud console for the development mode. Launched my app to my device with debogage mode
On the app : Just click on the button "register for push notification" and see 3 alerts
1) Device Token : " all numbers "
2) login success
3) Subscribed for Push Notification!
On the Appcelerator Cloud console :
Logs -> see login & subscribe, opened it and everything's ok
Push Notifications -> 1 Android clients subscribed to push notifications. And send one throught push notifications with alert & title
And nothing appears at all ... try reboot, try to turn the app off and send another one, nothing.
I was using a device (LG OPTIMUS ONE) with android 2.2.1 with internet on it (wifi). So, I tried with another phone (SAMSUNG GALAXY S2) 3.3.2 with internet on it (wifi)
And the only change is in the cloud console :
Push Notifications -> 2 Android clients subscribed to push notifications.
But it is the same, no notification appears.
Please, I really need help for this, I succeed with iOS in 2 days and I do not understand what is the big deal here ?
I don't think I need to register with Google C2DM for using ACS.
ACS use MQTT protocol for sending push.
(I followed this step by step tut : http://www.titaniumtutorial.com/2012/06/appcelerator-cloud-push-notification-in.html)
Have you already done one project with push notification on Android & Ti ?
I checked my settings and everything is fine.
But, because I'm desperate, I also register to C2DM and nothing better, I guess I have to wait a bit more before testing.
I use the upush module in the Marketplace, took me 10 minutes to gtet it up and running, saved me loads of time.
Have you registered with Google C2DM? You need to fill out the form at https://developers.google.com/android/c2dm/signup to send notifications to the device. Make sure you have your correct App ID in the Appcelerator Cloud Settings.