how to remove footer in flutter inappwebview - flutter-inappwebview

I have been able to remove footer in flutter webview but I am not able to remove footer in flutter inappwebview.
webViewController
.evaluateJavascript(
source: "javascript:(function() { " +
"var head = document.getElementsByClassName('site-footer')[0].style.display = 'none'; " +
"})()")
.then((value) =>
debugPrint('Page finished loading Javascript'))
.catchError((onError) => debugPrint('$onError'));

Related

Huawei HMS maps not working on Ionic Capacitor runtime

I have followed this guide to add Huawei HMS maps to my IONIC capacitor runtime app.
https://github.com/HMS-Core/hms-cordova-plugin/tree/master/cordova-plugin-hms-map/example/ionic
This app has google-services.json and huawei agconnect-services.json.
In project build.gradle I'm using
[...]
classpath 'com.huawei.agconnect:agcp:1.5.2.300'
capacitor.build.gradle
dependencies {
[...]
implementation "com.huawei.hms:base:5.2.0.300"
implementation "com.huawei.hms:maps:6.0.1.304"
}
Here are the npm libs
npm install #hmscore/cordova-plugin-hms-map#latest
npm install #ionic-native/core #hmscore/ionic-native-hms-map#latest
Set the appropriate sha2 figerprint in the Huawei developer console. App build.gradle.
signingConfigs {
config {
storeFile file('huawei.jks')
storePassword '*****'
keyAlias 'mapshowcase'
keyPassword '*****'
}
}
dependencies {
[...]
implementation 'com.huawei.agconnect:agconnect-core:1.5.2.300'
}
async initMap() {
const mapOptions = {
mapType: MapType.MAP_TYPE_TERRAIN,
cameraPosition: {
target: {lat: 40.7587658, lng: 30.3146964},
zoom: 2
}
};
this.hmsMap.requestPermission();
this.map = await this.hmsMap.getMap('map', mapOptions, {marginTop: 50});
this.addListener();
this.map.setMyLocationEnabled(true);
this.map.getUiSettings().setMyLocationButtonEnabled(true);
this.map.getProjection().getVisibleRegion().then(vr => console.log(JSON.stringify(vr)));
this.map.getProjection().toScreenLocation({lat: 12, lng: 43}).then(point => console.log(JSON.stringify(point)));
this.map.getProjection().fromScreenLocation({x: 300, y: 600}).then(latLng => console.log(JSON.stringify(latLng)));
}
Testing on a Huawei Harmony OS phone, but geting this error.
E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log : ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='5 : Unknown Code - 5'}
com.huawei.hms.maps.foundation.client.mac: * * *n*n*w* *o*e*-*5
at com.huawei.hms.maps.foundation.client.mac$maa.b(Unknown Source:25)
at com.huawei.hms.maps.foundation.client.mab.a(Unknown Source:20)
at com.huawei.hms.maps.foundation.client.mab.c(Unknown Source:80)
at com.huawei.hms.maps.foundation.client.mab.a(Unknown Source:88)
at com.huawei.hms.maps.provider.client.tile.maa.a(Unknown Source:1)
at com.huawei.hms.maps.provider.client.tile.maa.lambda$gI3f4RyIuh0G4Qoia5V0XosFnEE(Unknown Source:0)
at com.huawei.hms.maps.provider.client.tile.-$$Lambda$maa$gI3f4RyIuh0G4Qoia5V0XosFnEE.call(Unknown Source:6)
at com.huawei.hms.maps.foundation.client.mab$maa.a(Unknown Source:3)
at com.huawei.hms.maps.provider.client.tile.maa.c(Unknown Source:23)
at com.huawei.hms.maps.provider.client.tile.maa.a(Unknown Source:4)
at com.huawei.hms.maps.provider.cache.mag.a(Unknown Source:63)
at com.huawei.hms.maps.provider.cache.mag$mac.startUrlRequest(Unknown Source:2)
at com.huawei.map.MapController.startUrlRequest(Unknown Source:28)
Fo far I have not found any solution or details about such error on internet. Any help is appreciated.
Update 1
Looks like the map is properly constructed:
I/Capacitor/Console: File: http://localhost/ - Line 6588 - Msg: Huawei map constructed with the div id map :: and the props 1
But the target map div stays in blank and when I tap on it I'm able to see the clicks being logged.
addListener() {
const log = document.getElementById('log');
this.map.on(MapEvent.ON_MAP_CLICK, (latLng) => {
log.innerHTML = '<br>' + 'Map_Click:' + latLng.lat + '<-->' + latLng.lng + log.innerHTML;
});
this.map.on(MapEvent.ON_MAP_LONG_CLICK, (latLng) => {
log.innerHTML = '<br>' + 'Map_Long_Click:' + latLng.lat + '<-->' + latLng.lng + log.innerHTML;
});
}
Update 2
The issue is with the transparency of the parent div of the map div. The plugin does not set the background transparent to all its parent nodes automatically on map init.
The issue was solved by setting all map div's parent ion-content nodes'css value when map has to be shown and remove it when map page is destroyed.
global.scss
--ion-background-color: var(--map-background, white);
.background-transparent {
--map-background: transparent !important;
}
Map.page.ts
ionViewDidEnter(){
document.body.classList.toggle('background-transparent', true);
}
ionViewWillLeave(){
document.body.classList.toggle('background-transparent', false);
}
The provided log is not enough.
It is better to create ticket here: https://developer.huawei.com/consumer/en/support/feedback/#/
And put all the log file in the ticket.
Or you can search "HmsMap" and share the search result here.

Flutter: how to create post request with form data same js code

I want to upload an image to the server with flutter, in js t use form data with input file but with flutter I don't know what to do.
in js:
formData.append("file", e.clipboardData.files[0]);
formData.append("session", sessionid);
formData.append("fileindex", fileListIndex);
var hostname = window.location.hostname;
var protocol = window.location.protocol;
if (hostname === "localhost") {
xhr.open("POST", "http://localhost:9999/" + uploadpoint, true);
} else if (hostname === "www.aladin.finance") {
xhr.open("POST", protocol + "//uploadfile.aladin.finance" + "/"
+ uploadpoint, true);
} else {
xhr.open("POST", protocol + "//uploadfile." + hostname + "/"
+ uploadpoint, true);
}
xhr.withCredentials = true;
xhr.send(formData);
Flutter has this great package called Dio to handle all sort of http requests. It's very easy to do what you want with it. Check this: https://pub.dev/packages/dio#sending-formdata

I am trying to implement push notification in ionic v1using onesignal-cordova-plugin,fcm.But it's not working.My app.js is given below

var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
window.plugins.OneSignal.init("MY APP ID",
{googleProjectNumber:"Project Number"},
notificationOpenedCallback);
// Show an alert box if a notification comes in when the user is in your app.
window.plugins.OneSignal.enableInAppAlertNotification(true);

Disable animation on specific view/state in ionic

I have added a custom "in/out" animation on a state called "browser" with Native Page Transitions using this inside my controller
$scope.$on('$ionicView.beforeEnter', function() {
// animate things on devices
window.plugins.nativepagetransitions.slide(
{"direction":"up"},
function (msg) { // called when the animation has finished
console.log("success: " + msg);
},
function (msg) {
alert("error: " + msg);
}
);
});
$scope.$on('$ionicView.beforeLeave', function() {
// animate things on devices
window.plugins.nativepagetransitions.slide(
{"direction":"down"},
function (msg) { // called when the animation has finished
console.log("success: " + msg);
},
function (msg) {
alert("error: " + msg);
}
);
});
It works...kind of. The default transition (slide left/right) still works given my "slide up" animation a feeling of "slide in diagonal".
Is there a way to prevent the default transition of being triggered?
This is my view
<ion-view >
<ion-nav-bar animation="no-animation">
</ion-nav-bar>
<ion-nav-view animation="no-animation"></ion-nav-view>
<ion-nav-buttons>
<span class="ion-android-close close_browser" ng-click="goBack()"></span>
</ion-nav-buttons>
<ion-nav-title>
<img src="img/logo_header.png">
</ion-nav-title>
<ion-content>
<iframe class="browser" src="{{externalURL}}"></iframe>
</ion-content>
Those animation="no-animation" doesn't work...
ionic: 1.1.1
The solution was to put this before the $state.go()
$ionicHistory.nextViewOptions({
disableAnimate: true
});

phonegap - using external site as app - facebook login

I'm building a app site running through phone gap. Phone gap simply checks the user has internet connection and loads an external web app into the frame. I can navigat through the site fine with no blibs but as soon as I try the login to Facebook (either PHP redirect or javascript SDK) the app suddenly gets its navbar back or opens a new window (javascript SDK).
Is there anyway I can prevent this?
regards
It took some doing but using the ChildBrowser plugin, I've managed to login! (this is for android) I've used some code from a facebook connect plugin which didnt work for me, re wrote some stuffs so I could understand it and now works. Chears Juicy Scripter!
var fb_success = 'https://www.facebook.com/connect/login_success.html';
var fb_logout = 'https://www.facebook.com/connect/login_failed.html';
var fb_logout_ = 'http://m.facebook.com/logout.php?confirm=1&next=' + fb_logout;
var authorize_url = '';
var my_client_id = '##################';
var my_secret = '######################';
var my_type = 'user_agent';
var my_display = 'touch';
var token = false;
var fb_code = false;
var device_ready = false;
var ajax_url = '';
function logged_in(){
// alert('do what you need to do!');
}
function fb_force_logout(){
}
function fb_auth_check(){
console.log('fb_auth_check()');
if( fb_code !== false ) {
console.log('ajax test instigated...');
ajax_url = 'https://graph.facebook.com/oauth/access_token?client_id=' + encodeURIComponent(my_client_id) + '&client_secret=' + encodeURIComponent(my_secret) + '&code=' + encodeURIComponent(fb_code) + '&redirect_uri=' + fb_success;
$.ajax({
url: ajax_url,
type: 'POST',
success: function(html){
token = html.split("=")[1];
console.log('success! token = ' + token);
window.plugins.childBrowser.close();
fb_init();
},
error: function(error) {
console.log('there was an error...' + ajax_url);
window.plugins.childBrowser.close();
}
});
}
}
function fb_track_redirects(loc){
console.log('redirect tracked... ' + loc);
if ( loc.indexOf(fb_success) >= 0 || loc.indexOf(fb_success) > -1 ) {
fb_code = loc.match(/code=(.*)$/)[1]
console.log('success redirect... fb_code=' + fb_code);
fb_auth_check();
window.plugins.childBrowser.close();
} else if ( loc.indexOf(fb_logout) >= 0 || loc.indexOf(fb_logout) > -1 ) {
window.plugins.childBrowser.close();
}
}
function inner_init(){
console.log('inner_init()');
if( token === false ) {
console.log('token was false...');
authorize_url += "https://graph.facebook.com/oauth/authorize?";
authorize_url += "client_id=" + encodeURIComponent(my_client_id);
authorize_url += "&redirect_uri=" + encodeURIComponent(fb_success);
authorize_url += "&display=" + encodeURIComponent(my_display);
authorize_url += "&scope=publish_stream,offline_access";
console.log('instigated location change...');
window.plugins.childBrowser.onLocationChange = function(loc){
fb_track_redirects(loc);
}
console.log('open Facebbok login window');
window.plugins.childBrowser.showWebPage(authorize_url);
}else{
logged_in();
}
}
function fb_init(){
console.log('fb_init()');
if( device_ready === false ) {
console.log('first device run...');
document.addEventListener("deviceready", function(){
device_ready = true;
console.log('device ready...');
inner_init();
}, false);
}else{
inner_init();
}
}
$(document).ready(function(){
$('#login').bind('click', function(){
fb_init();
return false;
})
});
</script>
This is how it works for all apps native or web without patching the SDK code.
This is probably can be done, but will require digging into code. The question is do you really need it? This is a desired behavior.
You can try to use PhoneGap Facebook plugin and enable Single Sign On so native Facebook App if exists will be opened instead of browser to authenticate the user.
BTW,
Apps that are just external sites wrapped mostly rejected in app store.
Update:
Where is some points that may be also helpful in answer (by Facebook employee) to similar question How can I use an access token to circumvent FB.login().
Also have a look on ChildBrowser PhoneGap plugin (and Example).