In the React app, downloading an image from an iPhone to wi-fi is very slow, on the mobile Internet it’s excellent. Has anyone come across? - iphone

There is an application written in React. Images are loaded using the following code:
<input type='file' id='single-file' onChange={props.onChange}/>
onChange = e => {
let ua = navigator.userAgent;
let is_ie = ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
if (is_ie === true) {
let file = document.getElementById('single-file').files[0];
this.props.uploadImage(file);
this.props.openUpload(true);
} else {
this.props.uploadImage(e.target.files[0]);
this.props.openUpload(true);
e.target.value = '';
}
};
sent as standard with axios module using FormData.
When testing, it was found that from the PC, and Android phones, sending files happens quickly and normally. But on the iPhone on the mobile Internet of the network, the photo is sent perfectly, but it takes about two to three minutes with wi-fi. Different iPhones (X, XR, 6, 7), different browsers, different wi-fi networks were tested - the result is the same.
Maybe someone faced a similar problem?

Related

detecting if the current code is running as an app or as web page

I'm developing an hybrid application using ionic.
Most of the features would work on mobile web browser. So the final product can be used from an http address as well. But there are certain code segments/features ( such as vibration, background alerts ) which will obviously be for the app version. And those features will only be available on the app version.
What's a good/recommended way to detect the current situation in the code base so that I can do logic such as if (isRunningAsApp) {do this} else {do that}*?
would it be just checking window.location.href and if you get something that starts wiih http:, then it is a mobile app, otherwise it is an app?
This is from Ionic's documentation
angular.module('PlatformApp', ['ionic']).controller('PlatformCtrl', function($scope) {
ionic.Platform.ready(function(){
// will execute when device is ready, or immediately if the device is already ready.
});
var deviceInformation = ionic.Platform.device();
var isWebView = ionic.Platform.isWebView();
var isIPad = ionic.Platform.isIPad();
var isIOS = ionic.Platform.isIOS();
var isAndroid = ionic.Platform.isAndroid();
var isWindowsPhone = ionic.Platform.isWindowsPhone();
var currentPlatform = ionic.Platform.platform();
var currentPlatformVersion = ionic.Platform.version();
ionic.Platform.exitApp(); // stops the app
});

iPhone phonegap image disappearing after the phone sits for some time

I am using phonegap 2.0.0 on iOS and using basically the stock image capture code. After the image is captured it is saved to the phone, the URI is saved to the database along with the rest of the items info and the image is displayed on the page.
All this is working on both iOS and android. The issue is that when the iOS phone is turned off and allowed to sit for a period of time (overnight) the images no longer display. The rest of the data is retrieved from the database and displayed but the images just show a black square where the image should be (indicating the info is still inn the database)
Does iOS rename images after being turned off and allowed to sit for a some time? any suggestions? if the phone is turned off and back on this does not happen.. only after the phone sits for some time...
this seems very relevant...
Capturing and storing a picture taken with the Camera into a local database / PhoneGap / Cordova / iOS
for anybody else having this issue the following code worked for me...
function capturePhoto() {
navigator.camera.getPicture(movePic, onFail,{ quality : 70 });
}
function movePic(file){
window.resolveLocalFileSystemURI(file, resolveOnSuccess, resOnError);
}
function resolveOnSuccess(entry){
var d = new Date();
var n = d.getTime();
var newFileName = n + ".jpg";
var myFolderApp = "myPhotos";
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
fileSys.root.getDirectory( myFolderApp,
{create:true, exclusive: false},
function(directory) {
entry.moveTo(directory, newFileName, successMove, resOnError);
},
resOnError);
},
resOnError);
}
function successMove(imageUri) {
document.getElementById('smallImage').src = imageUri.fullPath;
//hidden input used to save the file path to the database
document.getElementById('site_front_pic').value = "file://"+imageUri.fullPath;
smallImage.style.display = 'block';
}
function onFail(message) {
alert('Failed to load picture because: ' + message);
}
function resOnError(error) {
alert(error.code);
}

differentiate between iPhones and iPads

I'm working on my mobile site, I already have this code:
<script type="text/javascript"> // <![CDATA[
if ( (navigator.userAgent.indexOf('Android') != -1) ) {
document.location = "android.html";
} // ]]>
</script>
which diverts android users away from the current page on to androids own dedicated page.
what I would like to do is the same thing but for an iphone / ipad. I would like iphone / ipod touch to land on iphone.html and ipad to land on ipad.html displaying different content for both. How can I do this?
thank you.
You can just expand your current approach to the other user agents:
var iphone = ((window.navigator.userAgent.match('iPhone'))||(window.navigator.userAgent.match('iPod')))?true:false;
var ipad = (window.navigator.userAgent.match('iPad'))?true:false;
if(iphone){
document.location = 'iphone.html';
}
if(ipad){
document.location = 'ipad.html';
}

DigitalDJ / AudioStreamer not connect to streaming server

I downloaded the code DigitalDJ / AudioStreamer to use in a player I'm doing, here's the project that I downloaded: https://github.com/DigitalDJ/AudioStreamer
Have used this library before I decided to upgrade it supports multi-thread,
but when I change the address of the streaming server http:// thor.nickpack.com:9000 to the address of my server, it does not run the audio.
to replace the server path that is in a TextField in viewController to my path: http:// 184.154.37.132:7075 see my problem.
Another solution would be to modify the old player that supports multi thread, I've tried several codes and could not, that was when I found the DigitalDJ / AudioStreamer, but I came across the problem I mentioned above,
this is the link for a sample app that does not have multi thread: http://www.mediafire.com/?eb7a6a87e8tqcbc
if someone has a clue how to implement audio in backgorund or how to solve the problem of streaming server I am grateful.
after a long time and almost going crazy trying to solved the problem by commenting the code in this trexo AudioStreamer.m
// hintForMIMEType
//
// Make a more informed guess on the file type based on the MIME type
//
// Parameters:
// mimeType - the MIME type
//
// returns a file type hint that can be passed to the AudioFileStream
//
/*
+ (AudioFileTypeID)hintForMIMEType:(NSString *)mimeType
{
AudioFileTypeID fileTypeHint = kAudioFileMP3Type;
if ([mimeType isEqual:#"audio/mpeg"])
{
fileTypeHint = kAudioFileMP3Type;
}
else if ([mimeType isEqual:#"audio/x-wav"])
{
fileTypeHint = kAudioFileWAVEType;
}
else if ([mimeType isEqual:#"audio/x-aiff"])
{
fileTypeHint = kAudioFileAIFFType;
}
else if ([mimeType isEqual:#"audio/x-m4a"])
{
fileTypeHint = kAudioFileM4AType;
}
else if ([mimeType isEqual:#"audio/mp4"])
{
fileTypeHint = kAudioFileMPEG4Type;
}
else if ([mimeType isEqual:#"audio/x-caf"])
{
fileTypeHint = kAudioFileCAFType;
}
else if ([mimeType isEqual:#"audio/aac"] || [mimeType isEqual:#"audio/aacp"])
{
fileTypeHint = kAudioFileAAC_ADTSType;
}
return fileTypeHint;
}*/
with this code commented out the audio played without problems on my server
I had problems connecting to MP3 stream with AudioStreamer. The sample would work on Simulator but not on device. I think because simulator isnt exact copy of ios device. On Simulator it uses the quicktime installed on the mac.
For local MP3 files use AVAudioPlayer.
For remote MP3 streams Use AVPlayer.
A good sample project is at
https://github.com/valvoline/CPStreamPlayer
Often remote streams take time to connect to time out. This sample shows that its buffering.
Search Github for AVPlayer theres a few samples.
CPStreamPlayer/AVPlayer supports redirects so for us we had
http://stream.fireplayer.com/greyhound/dyn?action=stream.StreamMix&id=1785
BUT THIS REDIRECTED TO GENERATE Mp3 file/stream on Amazon
http://s3.amazonaws.com/fireplayer_mp3/1785.mp3?AWSAccessKeyId=AKIAJAHV5HUV4TVRF5VA&Expires=1337595252&Signature=c%2FH%2FO9AACkovm%2BAhbWyD7E9Hb6A%3D";

Uploading files with PhoneGap + iPhone

I understand that PhoneGap applications are largely (if not entirely) HTML5 + CSS + JavaScript. Natively, the iPhone doesn't provide controls to upload files.
Does PhoneGap provide any mechanisms that allow users to upload files? (images / video, in the case of the iPhone)
I know Titanium allows users to do this, but it's a different animal with its compiled Javascript and proprietary APIs. Thanks for your advice/input.
I believe you might be able to read the files using the PhoneGap API and the upload them using and AJAX post if the server application supported it.
The other option is to write a custom module/Plugin in PhoneGap that could specific to your needs.
Here are some Example Plugins
You can do an xmlhttprequest to the file on a local drive.
I'm not 100% sure if it will work on the iPhone, but webkit should support it.
function getImageBinaries(url) { //synchronous binary downloader for firefox2
var req = new XMLHttpRequest();
req.open("GET", url, false);
req.overrideMimeType('text/plain; charset=x-user-defined');
req.send("");
if (req.status != 200) {
return "";
}
var t = req.responseText || "" ;
var ff = [];
var mx = t.length;
var scc= String.fromCharCode;
for (var z = 0; z < mx; z++) {
ff[z] = scc(t.charCodeAt(z) & 255);
}
var b = ff.join("");
return b;
}
Succes,
Erik