Caller.swift
2.99キロバイト
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// caller.swift
// jacket_test_ios
//
// Created by USER on 2017/10/11.
// Copyright © 2017年 ドラッサル 亜嵐. All rights reserved.
//
import Foundation
import UIKit
import CoreAudioKit
import UserNotifications
class Caller:NSObject{
public static let sheardInstance:Caller = Caller()
var proximityFillter:Int = 50
public func setProximityNofitication(proximityFillter:Int){
self.proximityFillter = proximityFillter
}
public func proximityNofiticationTrigger(){
NSLog("SenserData.sheardInstance.proximity")
if let proximity = SenserData.sheardInstance.proximity{
NSLog(String(proximity))
proximityNofitication(proximity,fillter:proximityFillter)
}
}
private func proximityNofitication(_ data:Int?, fillter:Int){
if let data = data {
if(data > fillter ){return}
if #available(iOS 10.0, *) {
UserNofitication.sharedInstance.easyNofitication(
/* nofitication detail */
identifier : "nofity",
title : "データが届きました",
body : String(data) + "cm",
actions : [
UNNotificationAction(
identifier: "possitive",
title: "",
options:[])], completionHandler: ({(Error)->Void in
}),
/* response callback */
response : UNResponseManager.sharedInstance.setResponse(identifier: "nofity") {(_ actionIdentifier:String) in
switch actionIdentifier {
case "positive":
break
case UNNotificationDismissActionIdentifier:
/* 選択せずにnofiticationを消去の場合*/
break
case UNNotificationDefaultActionIdentifier:
/* 選択せずにアプリ起動場合*/
break
default:
break
}
})
} else {
// Fallback on earlier versions
}
}
}
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert], completionHandler: { (granted, error) in
if error != nil {
print(error?.localizedDescription as Any)
return
}
})
}
return true
}
}