I'm having trouble getting angularjs working on windows phone 7 with phonegap. The simple stiff works, but as soon as I try to add page include or a view (route) it doesn't do anything. In the function matchUrl(url,obj) in angular.js (1.0.3) there is a regex that fails because Windows Phone use an unusual URL format.
What happens is angular is expecting a url like 'http://localhost/www/index.html' but in windows phone it will look like: 'x-wmapp0:app/www/index.html' instead.
Has anyone run across this and is there a solution?
This issue is as of now still unresolved and tracked here
https://github.com/angular/angular.js/issues/2303
EDIT:
The mentioned issue is still open although fix was submitted.
I managed to get a basic angular app running in phonegap WP7 by
applying the mentioned fix
including jquery (2.0.3) above angular.js
changing line of code in angular from
var xhr = new XHR();
to
var xhr = new XMLHttpRequest();
manually bootstrapping angular app after cordova deviceready event fired
I reported it here
Using angularjs-1.1.5 and changing line 5612 with
var SERVER_MATCH = /^([^:]+):[\/\/]*(\w+:{0,1}\w*#)?(\{?[\w\.-]*\}?)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/,
should fix the problem
Related
I'm trying to make a simple web api call using HttpClient in an iOS build. When setting the client.BaseAddress, the BaseAddress always ends up null. I can't find what could possibly be wrong.
using System.Net.Http;
....
private const string BaseApiUrl = "http://localhost:55904/";
static HttpClient client = new HttpClient();
client.BaseAddress = new Uri(BaseApiUrl);
// client.BaseAddress is still null
I downloaded a sample non-Xamarin project and the same code works fine.
Any ideas?
Update
As I continue messing with this I figured I would try some of the other platforms. UWP seems to work fine. I was going to test Android but all of a sudden, I have a bunch of "The name 'InitializeComponent' does not exist in the current context" errors.
I'm new to Xamarin but not to VS or C#.
Update
I was just thinking, does iOS need to request any special permission for internet access? If so, where would that be set?
Just in case anyone else comes across this problem, I found the cause. It turns out that the iOS project didn't include a reference to System.Net.Http. Once I added the reference, everything worked fine.
I compiled my reactjs using webpack and got a bundle file bundles.js. My bundles.js contains a component that make API calls to get the data.
I put this file in my html and pass the url to phantom.js to pre-compile static html for SEO reasons.
I am witnessing something strange here, the ajax calls for APIS are not getting fired at all.
For example, I have a component called Home which is called when I request for url /home. My Home component makes an ajax request to backend (django-rest) to get some data. Now when I call home page in phantomjs this api call is not getting fired.
Am I missing something here?
I have been using React based app rendering in Phantomjs since 2014. Make sure you use the latest Phantomjs version v2.x. The problems with Phantomjs occur because it uses older webkit engine, so if you have some CSS3 features used make sure they are prefixed correctly example flexbox layout.
From the JS side the PhantomJS does not support many newer APIs (example fetch etc.), to fix this add the polyfills and your fine. The most complicated thing is to track down errors, use the console.log and evaluate code inside the Phantomjs. There is also debugging mode which is actually quite difficult to use, but this could help you track down complex errors. I used webkit engine based browser Aurora to track down some of the issues.
For debugging the network traffic, try logging the requested and received events:
var page = require('webpage').create();
page.onResourceRequested = function(request) {
console.log('Request ' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function(response) {
console.log('Receive ' + JSON.stringify(response, undefined, 4));
};
So I've been working on a xamarin PCL project targeting android and windows store app and I've had this issue for about two weeks now. One of the very first things this app does is to make an http request to a yahoo service when the user tries to search for something.
Now, on the windows store app project, this works just fine. However, whenever I'm debugging the android project, this fails miserably. It times out and I get a TaskAbortedException.
I've navigated with the browser within the android emulator to the restful service url and I do get a response in the browser but nothing when I make the http request. I have tried everything I could think of but no cigar. I have researched this for weeks now and I have yet to find an answer. It should be noted that I'm making the request within the PCL project with HttpClient.
Here's the code where this happens:
var queryUrl = string.Format(QUERY_URL_TEMPLATE, TickerSearch);
try
{
var requestTask = httpClient.GetStringAsync(queryUrl);
requestTask.ContinueWith(t =>
{
var responseDto = JsonConvert.DeserializeObject<TickerSearchResultDto>(t.Result);
TickerSearchResults = responseDto.ResultSet.Result;
});
}
catch (Exception ex)
{
}
Any help is greatly appreciated.
Is it possible to disable cache for the Webview control for a Windows Phone 8.1 runtime universal app? My App seems to be remembering the information it received the first time. My app logs me into a service and when I go back to rerun app in the emulator (without completing shutting down the emulator) it logs me in automatically rather than giving me the prompt. This behavior is in the NavigationCompleted handler if that helps explain a bit more on where I am hitting this issue.
If I were to shut off the emulator completely and then restart it then I am prompted for the login name and password again. I have gotten over this cache issue, when I was using the HttpClient in other part of my app, by sending the no-cache in the header as:
client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
Can I do something similar for the webview control?
Thank You!
here is the code which I used to clear the cookies which resolved my issue:
Windows.Web.Http.Filters.HttpBaseProtocolFilter myFilter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
var cookieManager = myFilter.CookieManager;
HttpCookieCollection myCookieJar = cookieManager.GetCookies(new Uri("target URI for WebView"));
foreach (HttpCookie cookie in myCookieJar)
{
cookieManager.DeleteCookie(cookie);
}
There is no way to do it programmatically.
But for the test purposes for Windows application you can do it manually - http://blogs.msdn.com/b/wsdevsol/archive/2012/10/18/nine-things-you-need-to-know-about-webview.aspx#AN7.
In my SenchaTouch 2 app the first lines in app.js read:
Ext.Loader.setConfig( {enabled: true, disableCaching: false} );
Ext.data.Connection.disableCaching = false;
Ext.data.JsonP.disableCaching = false;
Ext.data.proxy.Server.prototype.noCache = false;
Ext.Ajax.disableCaching = false;
The app compiles to the production version without errors or warnings. It loads and runs from the server. When I try to run it offline in Chrome, those 404 errors occur
GET http://myServer/m/Override/...=1346682646496 /m/Override/slider/Slider.js?_dc=1346682646496:1
GET http://myServer/m/app.json?1346682646693 /m/:6
which indicate that the timestamp of the disableCache parameter is appended to the GET requests. Therefore the application does not load offline. It hangs at the "Application is being loaded..." screen. How can I enable caching and avoid this _dc parameter?
The SDK version is 2.0.1.1
-- update: Found workaround. Integrated Slider.js in app.js
This is a known bug or rather the feature was not implemented properly. It didnt work for me in sencha 2.1 either.