Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from nfls/1.2.5
Browse files Browse the repository at this point in the history
1.2.5
  • Loading branch information
hqy2000 authored Nov 14, 2017
2 parents c51fc2e + 558496b commit 2bf27d5
Show file tree
Hide file tree
Showing 22 changed files with 937 additions and 748 deletions.
61 changes: 61 additions & 0 deletions ContentExtension/Base.lproj/MainInterface.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13770" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13770"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Notification View Controller-->
<scene sceneID="cwh-vc-ff4">
<objects>
<viewController id="M4Y-Lb-cyx" userLabel="Notification View Controller" customClass="NotificationViewController" customModule="ContentExtension" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN">
<rect key="frame" x="0.0" y="0.0" width="320" height="200"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="top" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hello World" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="280" translatesAutoresizingMaskIntoConstraints="NO" id="GcN-lo-r42">
<rect key="frame" x="0.0" y="0.0" width="320" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="9nH-OS-oRw"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AYr-VU-HwV">
<rect key="frame" x="0.0" y="40" width="320" height="160"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="GcN-lo-r42" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" symbolic="YES" id="6Vq-gs-PHe"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="trailing" secondItem="GcN-lo-r42" secondAttribute="trailing" symbolic="YES" id="L8K-9R-egU"/>
<constraint firstItem="AYr-VU-HwV" firstAttribute="top" secondItem="GcN-lo-r42" secondAttribute="bottom" id="Oha-xG-cUh"/>
<constraint firstItem="AYr-VU-HwV" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" id="SPX-P1-tT9"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="trailing" secondItem="AYr-VU-HwV" secondAttribute="trailing" id="bOf-fv-Fs4"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="bottom" secondItem="AYr-VU-HwV" secondAttribute="bottom" id="h7X-pY-P81"/>
<constraint firstItem="GcN-lo-r42" firstAttribute="top" secondItem="2BE-c3-nQJ" secondAttribute="top" symbolic="YES" id="mYS-Cv-VNx"/>
</constraints>
<viewLayoutGuide key="safeArea" id="2BE-c3-nQJ"/>
</view>
<extendedEdge key="edgesForExtendedLayout"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="200"/>
<connections>
<outlet property="body" destination="AYr-VU-HwV" id="gFy-jB-pBG"/>
<outlet property="label" destination="GcN-lo-r42" id="lpW-cU-7IG"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
38 changes: 38 additions & 0 deletions ContentExtension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>ContentExtension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.2.5</string>
<key>CFBundleVersion</key>
<string>7</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>UNNotificationExtensionCategory</key>
<string>notice</string>
<key>UNNotificationExtensionInitialContentSizeRatio</key>
<real>1</real>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.usernotifications.content-extension</string>
</dict>
</dict>
</plist>
32 changes: 32 additions & 0 deletions ContentExtension/NotificationViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// NotificationViewController.swift
// ContentExtension
//
// Created by hqy on 2017/11/9.
// Copyright © 2017年 胡清阳. All rights reserved.
//

import UIKit
import UserNotifications
import UserNotificationsUI

class NotificationViewController: UIViewController, UNNotificationContentExtension {

@IBOutlet var body: UILabel!
@IBOutlet var label: UILabel!
@IBOutlet weak var image: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any required interface initialization here.
}

func didReceive(_ notification: UNNotification) {
label.text = notification.request.content.title
label.sizeToFit()
body.text = notification.request.content.body
body.lineBreakMode = .byWordWrapping
body.numberOfLines = 0
body.sizeToFit()
}

}
64 changes: 38 additions & 26 deletions GameCenterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import UIKit
import Alamofire
import UITableView_FDTemplateLayoutCell
import SCLAlertView

class GameCenterViewController:UITableViewController{

Expand Down Expand Up @@ -40,35 +41,46 @@ class GameCenterViewController:UITableViewController{
}

override func viewDidLoad() {
tableView.estimatedRowHeight = 75
tableView.rowHeight = UITableViewAutomaticDimension
loadFromLocal()

Alamofire.request("https://api.nfls.io/game/list").responseJSON { response in
switch(response.result){
case .success(let json):

let info = ((json as! [String:AnyObject])["info"] as! [[String:Any]])
self.names.removeAll()
self.descriptions.removeAll()
self.urls.removeAll()
self.images.removeAll()
for detail in info {
self.names.append(detail["name"] as! String)
self.descriptions.append(detail["description"] as! String)
self.urls.append(detail["url"] as! String)
self.images.append(detail["icon"] as! String)
if #available(iOS 10, *) {
tableView.estimatedRowHeight = 75
tableView.rowHeight = UITableViewAutomaticDimension
loadFromLocal()

Alamofire.request("https://api.nfls.io/game/list").responseJSON { response in
switch(response.result){
case .success(let json):

let info = ((json as! [String:AnyObject])["info"] as! [[String:Any]])
self.names.removeAll()
self.descriptions.removeAll()
self.urls.removeAll()
self.images.removeAll()
for detail in info {
self.names.append(detail["name"] as! String)
self.descriptions.append(detail["description"] as! String)
self.urls.append(detail["url"] as! String)
self.images.append(detail["icon"] as! String)
}
UserDefaults.standard.set(self.names, forKey: "game_names")
UserDefaults.standard.set(self.urls, forKey: "game_urls")
UserDefaults.standard.set(self.descriptions, forKey:"game_descriptions")
UserDefaults.standard.set(self.images, forKey:"game_img")
self.tableView.reloadData()
break
default:
break
}
UserDefaults.standard.set(self.names, forKey: "game_names")
UserDefaults.standard.set(self.urls, forKey: "game_urls")
UserDefaults.standard.set(self.descriptions, forKey:"game_descriptions")
UserDefaults.standard.set(self.images, forKey:"game_img")
self.tableView.reloadData()
break
default:
break
}
}else{
let error = SCLAlertView(appearance: SCLAlertView.SCLAppearance(
showCloseButton: false
))
error.addButton("返回", action: {
self.navigationController?.popViewController(animated: true)
})
error.showError("错误", subTitle: "游戏中心需要iOS10及以上系统版本")
}

}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
Expand Down
1 change: 0 additions & 1 deletion General/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
IQKeyboardManager.sharedManager().enable = true
NetworkActivityIndicatorManager.shared.isEnabled = true
NetworkActivityIndicatorManager.shared.completionDelay = 0.5
//ZIKCellularAuthorization.request()
UMAnalyticsConfig.sharedInstance().appKey = "59c733a1c895764c1100001c"
UMAnalyticsConfig.sharedInstance().channelId = "App Store"
MobClick.start(withConfigure: UMAnalyticsConfig.sharedInstance())
Expand Down
Loading

0 comments on commit 2bf27d5

Please sign in to comment.