Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ca11b14
Showing
13 changed files
with
850 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
keelr-embed-demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// AppDelegate.h | ||
// keelr-embed-demo | ||
// | ||
// Created by Per-Olov Jernberg on 2014-06-09. | ||
// Copyright (c) 2014 Per-Olov Jernberg. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "ViewController.h" | ||
|
||
@interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
@property (strong, nonatomic) ViewController *controller; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// AppDelegate.m | ||
// keelr-embed-demo | ||
// | ||
// Created by Per-Olov Jernberg on 2014-06-09. | ||
// Copyright (c) 2014 Per-Olov Jernberg. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
|
||
@interface AppDelegate () | ||
|
||
|
||
@end | ||
|
||
@implementation AppDelegate | ||
|
||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
// Override point for customization after application launch. | ||
return YES; | ||
} | ||
|
||
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { | ||
NSLog(@"handleOpenURL %@", url); | ||
NSArray *components = [url.fragment componentsSeparatedByString:@"&"]; | ||
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init]; | ||
for (NSString *component in components) { | ||
NSArray *subcomponents = [component componentsSeparatedByString:@"="]; | ||
[parameters setObject:[[subcomponents objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] | ||
forKey:[[subcomponents objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; | ||
} | ||
NSLog(@"parameters %@", parameters); | ||
|
||
NSString *accessToken = [parameters objectForKey:@"access_token"]; | ||
if (accessToken) { | ||
[self.controller setAuthAccessToken:accessToken]; | ||
} else { | ||
[self.controller setAuthError:@"unknown"]; | ||
} | ||
return TRUE; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6154.17" systemVersion="13D65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> | ||
<dependencies> | ||
<deployment defaultVersion="1792" identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6153.11"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<scene sceneID="tne-QT-ifu"> | ||
<objects> | ||
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController"> | ||
<layoutGuides> | ||
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> | ||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> | ||
</layoutGuides> | ||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | ||
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<subviews> | ||
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3Fz-sF-b3y"> | ||
<rect key="frame" x="0.0" y="30" width="480" height="450"/> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
</webView> | ||
</subviews> | ||
<color key="backgroundColor" red="0.39185837743345386" green="0.44476805119741802" blue="0.66474011479591844" alpha="1" colorSpace="calibratedRGB"/> | ||
<constraints> | ||
<constraint firstAttribute="bottom" secondItem="3Fz-sF-b3y" secondAttribute="bottom" id="Ohe-uc-I9m"/> | ||
<constraint firstAttribute="trailing" secondItem="3Fz-sF-b3y" secondAttribute="trailing" id="lUC-Er-huU"/> | ||
<constraint firstItem="3Fz-sF-b3y" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" constant="30" id="n5z-PF-IjX"/> | ||
<constraint firstItem="3Fz-sF-b3y" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="w5d-qS-i5P"/> | ||
</constraints> | ||
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/> | ||
</view> | ||
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/> | ||
<connections> | ||
<outlet property="web" destination="3Fz-sF-b3y" id="6yb-NL-PbD"/> | ||
</connections> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | ||
</objects> | ||
</scene> | ||
</scenes> | ||
</document> |
53 changes: 53 additions & 0 deletions
53
keelr-embed-demo/Images.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
keelr-embed-demo/Images.xcassets/LaunchImage.launchimage/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"subtype" : "retina4", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"orientation" : "landscape", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "landscape", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>se.possan.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleURLTypes</key> | ||
<array> | ||
<dict> | ||
<key>CFBundleTypeRole</key> | ||
<string>Editor</string> | ||
<key>CFBundleURLName</key> | ||
<string>se.possan.demoapp</string> | ||
<key>CFBundleURLSchemes</key> | ||
<array> | ||
<string>demoapp</string> | ||
</array> | ||
</dict> | ||
</array> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UIMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UIStatusBarHidden</key> | ||
<false/> | ||
<key>UIStatusBarStyle</key> | ||
<string>UIStatusBarStyleLightContent</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// ViewController.h | ||
// keelr-embed-demo | ||
// | ||
// Created by Per-Olov Jernberg on 2014-06-09. | ||
// Copyright (c) 2014 Per-Olov Jernberg. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface ViewController : UIViewController<UIWebViewDelegate> | ||
|
||
@property (nonatomic, assign) IBOutlet UIWebView *web; | ||
|
||
- (void) setAuthAccessToken:(NSString *)accessToken; | ||
- (void) setAuthError:(NSString *)error; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// ViewController.m | ||
// keelr-embed-demo | ||
// | ||
// Created by Per-Olov Jernberg on 2014-06-09. | ||
// Copyright (c) 2014 Per-Olov Jernberg. All rights reserved. | ||
// | ||
|
||
#import "ViewController.h" | ||
#import "AppDelegate.h" | ||
|
||
@interface ViewController () | ||
|
||
@end | ||
|
||
@implementation ViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view, typically from a nib. | ||
|
||
NSString *redirect_uri = @"demoapp://"; | ||
NSString *client_id = @"democlientid"; | ||
NSString *sitename = @"demoapp"; | ||
|
||
[self.web setDelegate:self]; | ||
|
||
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://embed.keelr.com/v2/%@?client_id=%@&response_type=token&redirect_uri=%@", sitename, client_id, redirect_uri]]; | ||
|
||
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; | ||
app.controller = self; | ||
|
||
NSURLRequest *req = [NSURLRequest requestWithURL:url]; | ||
[self.web loadRequest:req]; | ||
} | ||
|
||
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType | ||
{ | ||
// NSLog(@"shouldStart: %@", request.URL); | ||
if ([request.URL.host containsString:@"keelr.com"] || | ||
[request.URL.host containsString:@"keelr2.com"]) { | ||
if (![request.URL.host containsString:@"login."]) { | ||
return TRUE; | ||
} | ||
} | ||
[[UIApplication sharedApplication] openURL:request.URL]; | ||
return FALSE; | ||
} | ||
|
||
- (void) setAuthAccessToken:(NSString *)accessToken { | ||
[self.web stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"_logincallback('%@');", accessToken]]; | ||
} | ||
|
||
- (void) setAuthError:(NSString *)error { | ||
[self.web stringByEvaluatingJavaScriptFromString:@"_logincallback(null);"]; | ||
} | ||
|
||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// main.m | ||
// keelr-embed-demo | ||
// | ||
// Created by Per-Olov Jernberg on 2014-06-09. | ||
// Copyright (c) 2014 Per-Olov Jernberg. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "AppDelegate.h" | ||
|
||
int main(int argc, char * argv[]) { | ||
@autoreleasepool { | ||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>se.possan.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.