objective c - How to detect php web page is running within my iPhone App other than Safari -
i have built iphone app(not ipad) , running webpage within web view controller. question how can php file detect being run within app's uiwebview controller not safari. want php page react differently(i.e. rid of html menu) if run within app safari mobile web browser. possible?
webview controller
#import "accountviewcontroller.h" @interface accountviewcontroller () @end @implementation accountviewcontroller - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidappear:(bool)animated { [super viewdidload]; nsurl *url = [nsurl fileurlwithpath:[[nsbundle mainbundle]pathforresource:@"account" oftype:@"html"]isdirectory:no]; nsurlrequest *requestobj = [nsurlrequest requestwithurl:url]; [_accountwebview loadrequest:requestobj]; } -(void)webviewdidfinishload:(uiwebview *)webview { nshttpcookiestorage *sharedhttpcookiestorage = [nshttpcookiestorage sharedhttpcookiestorage]; nsarray *cookies = [sharedhttpcookiestorage cookiesforurl:[nsurl urlwithstring:@"http://www.uniitee.com"]]; nsenumerator *enumerator = [cookies objectenumerator]; nshttpcookie *cookie; while (cookie = [enumerator nextobject]) { nslog(@"cookie{name: %@, value: %@}", [cookie name], [cookie value]); } } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
php file
<?php require_once('connections/uniitee.php'); $iphone = strpos($_server['http_user_agent'],"iphone"); $android = strpos($_server['http_user_agent'],"android"); $palmpre = strpos($_server['http_user_agent'],"webos"); $berry = strpos($_server['http_user_agent'],"blackberry"); $ipod = strpos($_server['http_user_agent'],"ipod"); if ($iphone || $android || $palmpre || $ipod || $berry == true) { header('location: login-m.php'); } ?>
you load different url parameter in app, such ?appview=true
, , in php use if($_get['appview'])
.
you set session app view true use throughout users session
Comments
Post a Comment