Reputation: 1291
I've built a mobile-ready website that does most of the features that an app would do. However, some people still like the idea of an 'app' on their phones because it would load the 'app' (website) directly, rather than having them load their browsers and type the URL.
Is there a way to create an app in Android and in iOS that works this way? The idea is that there's simply a custom icon reflecting the website, and once it's tapped it loads the browser with the URL of the website already input.
It seems like it would be simple enough to do in both Android and iOS, but scrolling through my reference books only yields concepts like putting a clickable URL inside a 'main screen' in the app, rather than effortless redirection.
Upvotes: 0
Views: 324
Reputation: 13222
For iOS a "mobile web shell" kind of applications will get rejected in the app review process.
From App review guidelines document (you will require to login with your AppleId),
2.12 Apps that are not very useful, unique, are simply web sites bundled as Apps, or do not provide any lasting entertainment value may be rejected
Which means that applications which merely wrap a UIWebView
to display the mobile site and do not support any other functionality/purpose will be rejected. Such shell applications can be achieved even through Safari browser which allows to "Add website to Home screen".
There is similar question asked previously on SO, please go through it: Does Apple reject “mobile web shell” applications?
Hope this helps!
Upvotes: 2
Reputation: 9835
As a disclaimer, I have absolutely no idea if apple would accept this for the app store, but to implement such a thing is extremely simple. Here is the only code I changed in the appDelegate:
#import "AppDelegate.h"
#import "WebViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
WebViewController *webVC = [[WebViewController alloc] initWithURLString:@"http://www.google.com"];
self.window.rootViewController = webVC;
[self.window makeKeyAndVisible];
return YES;
}
I then subclassed a UIViewController with the following .h and .m files:
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController <UIWebViewDelegate> {
NSString *_url;
}
- (id)initWithURLString:(NSString *)URLString;
@end
#import "WebViewController.h"
@interface WebViewController ()
@end
@implementation WebViewController
- (id)initWithURLString:(NSString *)URLString {
self = [super init];
_url = URLString;
return self;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight + UIViewAutoresizingFlexibleWidth;
webView.delegate = self;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
[self.view addSubview:webView];
}
-(void)webViewDidStartLoad:(UIWebView *)webView {
// perhaps show some sort of loading message here
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
// hide the loading message here
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
// also hide the loading message here and present the user with an appropriate error message
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
return YES;
}
@end
This resulted in the following:
Hope that helps!
Upvotes: 1
Reputation: 2359
If you wanted to build a native iOS app, you could use a simple UIWebView to load the page.
As an example, inside your root UIViewController:
NSString* url = @"http://google.com";
NSURL* nsUrl = [NSURL URLWithString:url];
NSURLRequest* request = [NSURLRequest requestWithURL:nsUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
[self.webView loadRequest:request];
Upvotes: 1
Reputation: 26027
For Android, I would say the comment by @A--C is correct. What you can do to improve the user experience is that have just one activity which is transparent. In the onCreate
function have a progress dialog showing some message. Since its transparent it will only show the dialog. Then from within the onCreate
just open the browser. It will seem to the user that you are just opening the browser. For making that single transparent activity do following:
<activity android:name=".your.activity.declaration.here"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
Basically add android:theme="@android:style/Theme.Translucent.NoTitleBar"
to your activity declaration in manifest.
Upvotes: 1