Skip to content

Instantly share code, notes, and snippets.

@KazuyukiEguchi
Created November 9, 2017 09:04
Show Gist options
  • Save KazuyukiEguchi/75eef8bc21de282ac78a7b4fa16e006c to your computer and use it in GitHub Desktop.
Save KazuyukiEguchi/75eef8bc21de282ac78a7b4fa16e006c to your computer and use it in GitHub Desktop.
MAMORIO SDK (iOS版) 最初の一歩 ref: http://qiita.com/KazuyukiEguchi/items/b044f38d820ba52d6174
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '9.0'
target 'Test Mamorio' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Test Mamorio
pod 'MamorioSDK', :git => 'https://github.com/otoshimono/mamorio-sdk-ios-bin.git'
end
//
// ViewController.swift
// Test Mamorio
//
// Created by Kazuyuki Eguchi on 2017/11/09.
// Copyright © 2017年 Kazuyuki Eguchi. All rights reserved.
//
import UIKit
import MamorioSDK
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// MAMORIO SDKを初期化
MamorioSDK.setUp("YOUR_APP_TOKEN")
// temp user
User.signUpAsTemporalUser() { [weak self] (user, error) -> Void in
if let error = error {
print("捜索専用ユーザーの登録に失敗しました。エラーメッセージ:\(error.description)")
} else {
print("捜索専用ユーザーの登録に成功しました。")
// メインスレッドでコールされるようにする
DispatchQueue.main.async {
self?.step2()
}
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func step2()
{
// MAMORIOを探す
MamorioSDK.rangingStart({() -> Void in
print("レンジングの開始に成功しました。")
}, onError: {(error) -> Void in
print("レンジングの開始に失敗しました。エラーメッセージ:\(error.description)")
}, onMamoriosEnter: {(mamorios : Array<Mamorio> , othersMamorios: Array<Mamorio>) in
print("MAMORIO発見 自分のMAMORIO=\(mamorios.count) , 他人のMAMORIO=\(othersMamorios.count)")
}, onMamorioExit: {(mamorio : Mamorio) in
print("自分のMAMORIOを見失いました。紛失を伝えましょう。")
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment