Skip to content

Commit 7394135

Browse files
authored
Merge pull request #4 from arturgrigor/develop
HTTPS support, API interface updates and Demo app
2 parents c8f8d71 + 0d995a2 commit 7394135

File tree

16 files changed

+851
-245
lines changed

16 files changed

+851
-245
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode11.2
2+
osx_image: xcode11.6
33
branches:
44
only:
55
- master
@@ -9,14 +9,14 @@ env:
99
- LANG=en_US.UTF-8
1010
- SCHEME="IPAPI"
1111
matrix:
12-
- DESTINATION="OS=4.0,name=Apple Watch Series 3 - 42mm" RUN_TESTS="NO" POD_LINT="NO"
12+
- DESTINATION="OS=6.0,name=Apple Watch Series 5 - 44mm" RUN_TESTS="NO" POD_LINT="NO"
1313
- DESTINATION="OS=3.2,name=Apple Watch - 42mm" RUN_TESTS="NO" POD_LINT="NO"
1414

15-
- DESTINATION="OS=13.2,name=iPhone 11 Pro Max" RUN_TESTS="NO" POD_LINT="NO"
15+
- DESTINATION="OS=13.6,name=iPhone 11 Pro Max" RUN_TESTS="NO" POD_LINT="NO"
1616
- DESTINATION="OS=10.3.1,name=iPad Air" RUN_TESTS="NO" POD_LINT="NO"
1717

18-
- DESTINATION="OS=13.2,name=Apple TV" RUN_TESTS="NO" POD_LINT="NO"
19-
- DESTINATION="OS=10.2,name=Apple TV 1080p" RUN_TESTS="NO" POD_LINT="NO"
18+
- DESTINATION="OS=13.4,name=Apple TV" RUN_TESTS="NO" POD_LINT="NO"
19+
- DESTINATION="OS=10.2,name=Apple TV" RUN_TESTS="NO" POD_LINT="NO"
2020

2121
- DESTINATION="arch=x86_64" RUN_TESTS="YES" POD_LINT="NO"
2222
script:

Demo iOS/AppDelegate.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// AppDelegate.swift
3+
// Demo iOS
4+
//
5+
// Created by Artur Grigor on 17/07/2020.
6+
// Copyright © 2020 Artur Grigor. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
15+
16+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
17+
// Override point for customization after application launch.
18+
return true
19+
}
20+
21+
// MARK: UISceneSession Lifecycle
22+
23+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
24+
// Called when a new scene session is being created.
25+
// Use this method to select a configuration to create the new scene with.
26+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
27+
}
28+
29+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
30+
// Called when the user discards a scene session.
31+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
32+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
33+
}
34+
35+
36+
}
37+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "76x76"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"scale" : "2x",
86+
"size" : "83.5x83.5"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"scale" : "1x",
91+
"size" : "1024x1024"
92+
}
93+
],
94+
"info" : {
95+
"author" : "xcode",
96+
"version" : 1
97+
}
98+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>

Demo iOS/ContentView.swift

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// ContentView.swift
3+
// Demo iOS
4+
//
5+
// Created by Artur Grigor on 17/07/2020.
6+
// Copyright © 2020 Artur Grigor. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
import IPAPI
11+
12+
enum Data {
13+
case none
14+
case loading
15+
case result(Swift.Result<IPAPI.Service.Result, Swift.Error>)
16+
17+
var text: String {
18+
switch self {
19+
case .none: return ""
20+
case .loading: return "Loading..."
21+
case .result(let innerResult):
22+
switch innerResult {
23+
case .failure(let error): return error.localizedDescription
24+
case .success(let apiResult): return String(describing: apiResult)
25+
}
26+
}
27+
}
28+
}
29+
30+
struct ContentView: View {
31+
static let pricingPlan: IPAPI.Service.PricingPlan = .free
32+
// static let pricingPlan: IPAPI.Service.PricingPlan = .pro(apiKey: "test-demo-pro"); #warning("Set your own API Key")
33+
34+
@State private var data: Data = .none
35+
private let service = IPAPI.Service(pricingPlan: Self.pricingPlan)
36+
37+
var body: some View {
38+
VStack {
39+
Text(self.data.text)
40+
.padding(.all)
41+
.multilineTextAlignment(.center)
42+
.lineLimit(nil)
43+
}.onAppear(perform: loadData)
44+
}
45+
46+
func loadData() {
47+
self.data = .loading
48+
self.service.fetch {
49+
self.data = .result($0)
50+
}
51+
}
52+
}
53+
54+
struct ContentView_Previews: PreviewProvider {
55+
static var previews: some View {
56+
VStack {
57+
ContentView()
58+
}
59+
}
60+
}

Demo iOS/Info.plist

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>NSAppTransportSecurity</key>
24+
<dict>
25+
<key>NSAllowsArbitraryLoads</key>
26+
<true/>
27+
</dict>
28+
<key>UIApplicationSceneManifest</key>
29+
<dict>
30+
<key>UIApplicationSupportsMultipleScenes</key>
31+
<false/>
32+
<key>UISceneConfigurations</key>
33+
<dict>
34+
<key>UIWindowSceneSessionRoleApplication</key>
35+
<array>
36+
<dict>
37+
<key>UISceneConfigurationName</key>
38+
<string>Default Configuration</string>
39+
<key>UISceneDelegateClassName</key>
40+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
41+
</dict>
42+
</array>
43+
</dict>
44+
</dict>
45+
<key>UILaunchStoryboardName</key>
46+
<string>LaunchScreen</string>
47+
<key>UIRequiredDeviceCapabilities</key>
48+
<array>
49+
<string>armv7</string>
50+
</array>
51+
<key>UISupportedInterfaceOrientations</key>
52+
<array>
53+
<string>UIInterfaceOrientationPortrait</string>
54+
<string>UIInterfaceOrientationLandscapeLeft</string>
55+
<string>UIInterfaceOrientationLandscapeRight</string>
56+
</array>
57+
<key>UISupportedInterfaceOrientations~ipad</key>
58+
<array>
59+
<string>UIInterfaceOrientationPortrait</string>
60+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
61+
<string>UIInterfaceOrientationLandscapeLeft</string>
62+
<string>UIInterfaceOrientationLandscapeRight</string>
63+
</array>
64+
</dict>
65+
</plist>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

Demo iOS/SceneDelegate.swift

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// SceneDelegate.swift
3+
// Demo iOS
4+
//
5+
// Created by Artur Grigor on 17/07/2020.
6+
// Copyright © 2020 Artur Grigor. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import SwiftUI
11+
12+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
13+
14+
var window: UIWindow?
15+
16+
17+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
18+
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
19+
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
20+
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
21+
22+
// Create the SwiftUI view that provides the window contents.
23+
let contentView = ContentView()
24+
25+
// Use a UIHostingController as window root view controller.
26+
if let windowScene = scene as? UIWindowScene {
27+
let window = UIWindow(windowScene: windowScene)
28+
window.rootViewController = UIHostingController(rootView: contentView)
29+
self.window = window
30+
window.makeKeyAndVisible()
31+
}
32+
}
33+
34+
func sceneDidDisconnect(_ scene: UIScene) {
35+
// Called as the scene is being released by the system.
36+
// This occurs shortly after the scene enters the background, or when its session is discarded.
37+
// Release any resources associated with this scene that can be re-created the next time the scene connects.
38+
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
39+
}
40+
41+
func sceneDidBecomeActive(_ scene: UIScene) {
42+
// Called when the scene has moved from an inactive state to an active state.
43+
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
44+
}
45+
46+
func sceneWillResignActive(_ scene: UIScene) {
47+
// Called when the scene will move from an active state to an inactive state.
48+
// This may occur due to temporary interruptions (ex. an incoming phone call).
49+
}
50+
51+
func sceneWillEnterForeground(_ scene: UIScene) {
52+
// Called as the scene transitions from the background to the foreground.
53+
// Use this method to undo the changes made on entering the background.
54+
}
55+
56+
func sceneDidEnterBackground(_ scene: UIScene) {
57+
// Called as the scene transitions from the foreground to the background.
58+
// Use this method to save data, release shared resources, and store enough scene-specific state information
59+
// to restore the scene back to its current state.
60+
}
61+
62+
63+
}
64+

0 commit comments

Comments
 (0)