how to open a site without closing an app - uiwebview

I have been opening websites in my app in the following:
NSURL * url = [[NSURL alloc] initWithString:#"http://www.google.com"];
[[UIApplication sharedApplication] openURL:url];
But this terminates the app before opening the site. How can I keep the app running in the background/paused while I open the site?

try this, its work properly
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:#"http://www.google.com"]];

Related

UIWebView Loading content properly on iOS 6 simulator but not on device?

I have encountered a weird bug with a released app. My UIWebView is no longer loading content on iOS 6, yet the content still displays in the simulator. The activity indicator displays properly but then it loads a blank url? Again, this only happens on a device, not on the simulator.
To provide extra context (in the simulator the NSURLRequest is assigned the proper URL. When run on a device the value is nil.)
Here is my code :
-(void)loading
{
if(!self.webView.loading)
[self.activityIndicator stopAnimating];
else {
[self.activityIndicator startAnimating];
}
}
- (void)viewDidLoad
{
[self.webView addSubview:self.activityIndicator];
NSURLRequest *requestUrl = [NSURLRequest requestWithURL:self.url];
[self.webView loadRequest:requestUrl];
self.timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:#selector(loading) userInfo:nil repeats:YES];
[super viewDidLoad];
NSLog(#"%#", requestUrl);
}
I had a similar issue with our web app (HTML+JS+CSS) not loading on a device, but working fine in a browser and iPhone Simulator. The cause of the issue was the wrong case in filenames. E.g., HTML file wanted to load a file 'Loader.js', whereas its name was 'loader.js'.
So, maybe you should check your 'self.url' (if your 'index.html' has the right case in its filename).
please use web view in nib and debug it to safari developer tools,
so you can trace the actual problem. I use this approach for my application and its working.
process to open developer tools
1-open safari
2-go to preference
3-go to advance option
4- set on to developer tools
After follow above process you can see your safari having option develop.
it means your safari developer tools is active and you can able to debug ios application

UIWebView not loading mobile twitter (iPad)

I try to load Twitter into my UIWebView Using loadHTMLString (after loading the DOM using an NSURLRequest), now the string I have contains the correct HTML.
It loads the twitter page, but then I only get the black bar showing a progress circle, is anyone familiar with this problem and knows how to solve it?
Why do you download the html first and try loading the UIWebView with loadHTMLString after?
I think you create some issue with the ajax 'magic' because you don't run the html from the same domain as your ajax calls. And it seems like cross site scripting.
I think you can better use something like this and really load in the twitter homepage.
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];

Secure Transaction between Mobile app and LAMP

I have a Mobile App (iPhone and Android) which allows user to login to his account, change prefs etc...
I want to add a new feature where the user can buy products through his device or upgrade his service. Everything will run from the device and I want to make each transactions the user make it syncs to the web server.
I have HTTPS setup on my server. I would like to know if:
It is a good practice? or should I simply tell the user to use our website
If "yes", is HTTPS alone good to process these transactions?
Thanks
yes it's a good practice.
first of all ALWAYS use HTTPS.
make sure your certificate is valid and trusted.
for iphone:
iPhone: HTTPS client cert authentication
https://discussions.apple.com/thread/1652697?start=0&tstart=0
for android:
Trusting all certificates using HttpClient over HTTPS
Accepting a certificate for HTTPs on Android
second encrypt your data.
any encryption algorithm or rsa encryption will do the trick.
passing data using GET/POST should not be sent in plain text like: ?user=myuser&pass=mypass. instead use something like ?h28JduDak30fT1pfgmSnShNms762023lflsfdj2h4J. then on your server you simply have to decrypt it using a salt only your phone and the server knows.
example code for iphone:
NSString *encrypteddata =[NSString stringWithFormat:#"key=enryptedstring"];
NSData *data = [encrypteddata dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *datalen = [NSString stringWithFormat:#"%d", [data length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:#"https://yourserver:443/loginscript"]]; //:443 very importantz
[request setHTTPMethod:#"POST"];
[request setValue:datalen forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:data];
similar idea for android
then on your server you can decrypt $_POST['key'] and do your login logic (or others)
here's more resource that will help you:
iPhone + sending data from iPhone to server as XML format
iPhone: HTTPS client cert authentication
note:
for android you shoud take a look at the HTTPComponents
read more
http://www.javamex.com/tutorials/cryptography/rsa_encryption.shtml
http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-receive-data-from-the-server-in-iphone/

how to activate Iad feature to iphone App

hi
i have worked in simple app in which i implement iad feature but i don't know how to activate iad feature to iphone app
plz out of snippet please give step to activate iad network and its functionality .
thanks in advance
You must be enrolled in the iOS Developer Program to join the iAd Network. Members need to do the following:
* Agree to the Developer Advertising Services Agreement in iTunes Connect.
* Set up your banking and tax information if you don’t have a paid app on the App Store.
* Enable your app for iAd ads in the Manage Your Applications module within iTunes Connect.
* Set up your iAd preferences in the iAd Network module within iTunes Connect.
You need to import the iAD Framework and also enable it for your app on iTunes Connect.
Then try the following...
iAdBanner = [[ADBannerView alloc] initWithFrame:CGRectMake(0.0, 245.0, 768.0, 66.0)];
if(&ADBannerContentSizeIdentifierPortrait != nil)
portrait = ADBannerContentSizeIdentifierPortrait;
else
portrait = ADBannerContentSizeIdentifier320x50;
if(&ADBannerContentSizeIdentifierLandscape != nil)
landscape = ADBannerContentSizeIdentifierLandscape;
else
landscape = ADBannerContentSizeIdentifier480x32;
iAdBanner.requiredContentSizeIdentifiers = [NSSet setWithObjects:landscape, nil];
iAdBanner.autoresizesSubviews = YES;
iAdBanner.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
iAdBanner.delegate = self;
[self.view addSubview:iAdBanner];
iAdBanner.hidden = NO;

App hangs on restart with latest Flurry SDK and ios4

I have a frustrating problem with the latest version of Flurry (Flurry iPhone SDK v2.5). When I start my app, quickly exit, then restart the App, the app briefly loads, flickers a black screen, then stays on the black screen. The black screen stays there until I press the home button, at which point I can restart the app normally. I looked into this further, and it turns out that app state delegates are getting called in the wrong order:
applicationDidBecomeActive //app finishes loading the first time
applicationWillResignActive //app begins to resign
applicationWillEnterForeground //At this point, I have quickly restarted the app, and this is called
applicationDidEnterBackground //When this delegate is called, the screen goes black
applicationDidEnterBackground //This gets called when I hit the home button again, after the screen has been hanging for a while.
So what I think this means is some processes take a bit longer to wrap up once I hit the home button, and if I try to start the app again too quickly there is some very odd behavior. If I wait a few seconds to restart the app, the app behaves normally.
To demonstrate this problem, I created the simplest app I could think of, which I will post here. I built this with XCode 3.2.3, in the 4.0 build directly onto my iphone device (iphone 4). This is important, because I couldn't reproduce this problem on the simulator. You can reproduce this app by creating a new navigation based project named simpleApp, and dropping this code in, with your own Flurry API key of course.
Here is simpleAppAppDelegate.m:
#import "simpleAppAppDelegate.h"
#import "RootViewController.h"
#import "FlurryAPI.h"
#implementation simpleAppAppDelegate
#synthesize window;
#synthesize navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FlurryAPI startSession:#"<your api key here>"];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
printf("applicationWillResignActive\n");
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
printf("applicationDidEnterBackground\n");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
printf("applicationWillEnterForeground\n");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
printf("applicationDidBecomeActive\n");
}
- (void)applicationWillTerminate:(UIApplication *)application {
printf("applicationWillTerminate\n");
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
}
- (void)dealloc {
[navigationController release];
[window release];
[super dealloc];
}
#end
And here is simpleAppAppDelegate.h:
#import <UIKit/UIKit.h>
#interface simpleAppAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *navigationController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
#end
So anyway, because so many apps are using Flurry I feel like I must be missing something very basic. What really boggles my mind is that I haven't found anyone at all complaining about this particular problem. Also, this is different from the problem in previous versions where the app would appear to start immediately, go black for a few seconds, then resume normally. That problem was solved by calling [FlurryAPI setSessionReportsOnCloseEnabled:false]; after I set the session, but that doesn't help in this case.
Anyway, has anyone else had this problem? I really hope it's just a stupid error on my part. I'm really excited to use Flurry but something like this would cause my app to get rejected.
I wrote Flurry about this and they got back to me really quickly that they'd look into this. About a week later they wrote back and said they fixed it in v2.6 which is now available. I can't seem to reproduce the problem anymore.
Not to say I'm awesome or anything, but I did kind of single handedly fix this bug.
I take this from flurry. Version 2.7 also has the problem but:
[FlurryAPI setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose];
This option is on by default. When enabled, Flurry will attempt to send session data when the app is exited as well as it normally does when the app is started. This will improve the speed at which your application analytics are updated but can prolong the app termination process due to network latency. In some cases, the network latency can cause the app to crash.
I'm not sure whether I should be answering my own question in a comment to the original post or to post an answer, but in any case here is the answer:
Flurry is broken, it's been confirmed by others on this apple dev forum thread (you need an account to login):https://devforums.apple.com/thread/56339?tstart=0
Here's hoping Flurry gets a new version out soon, I'd really like to incorporate their offerings into my app.
We just released a new version of the iPhone Flurry SDK that should resolve this issue. Please download this new SDK and let us know if it resolves the issue you are encountering.
--
Sincerely,
-Sheila
Flurry Support

Resources