I am using ionic framework and Angular JS.
I am not sure where to start to track start of a web request.
For end request, I write a directive with onLoad tag.
here is the code
Directive.js
app.directive('iframeOnload', [function(){
return {
scope: {
callBack: '&iframeOnload'
},
link: function(scope, element, attrs){
element.on('load', function(){
return scope.callBack({DOMelement: this});
})
}
}}]);
At the HTML
<iframe id="webFrame" iframe-onload="iframeLoadedCallBack()" style="width:100%;height:650px;" ng-src='{{goToURL}}' ng-hide='hideIFrame'></iframe>
At the Controller The callback function is
$scope.iframeLoadedCallBack = function() {
console.log('iframeLoadedCallback');
// finished web request callback do something here
};
I guess there is something similar for start of the web request. And I need to track the send request URL.
I am an iOS developer, And actually I would like to do something similar to this protocol UIWebViewDelegate.
Thanks a lot
Although it may not work perfectly, at the iframeLoadedCallback
you could add the following code
var webFrame = angular.element(document.getElementById('webFrame'));
webFrame[0].contentDocument.onclick = $scope.clickOnIframe;
and it will track every click event inside the iframe, rest of it would be hard code to track by ID, tag, class etc inside the event.
I hope it helps someone has similar question.
You can track all web requests using NSURLProtocol hope this may help.