Skip to content

Instantly share code, notes, and snippets.

View ennioma's full-sized avatar
🎯
Focusing

Ennio Masi ennioma

🎯
Focusing
View GitHub Profile
func stopSession() {
if let reader = reader {
reader.invalidate()
}
}
override func viewDidLoad() {
super.viewDidLoad()
let reader = NFCNDEFReaderSession.init(delegate: self, queue: nil, invalidateAfterFirstRead: false) //1
reader.begin() //2
}
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
print(error.localizedDescription)
}
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
for message in messages {
for record in message.records {
print("Record Type Id \(record.typeNameFormat)")
print("Record Type \(record.type)")
print("Record Payload \(record.payload)")
print("Record Identifier \(record.identifier)")
}
}
}
import UIKit
import arek
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let config = ArekConfiguration(frequency: .JustOnce, presentInitialPopup: true, presentReEnablePopup: true)
@ennioma
ennioma / OAuth2_doorkeeper_AFOAuth2Manager
Created March 6, 2015 11:36
OAuth2 using doorkeeper + AFOAuth2Manager
/*
https://github.com/gottfrois/doorkeeper-provider-app
curl -i http://localhost:5100/oauth/token -F grant_type="password" -F username="john.smith@myapp.com" -F password="please" -F client_id="5c13e1fdd1007229121176ec372e5d9cda2698f37f243a3965c1176bce1ecd01" -F client_secret=","
*/
NSString *kClientID = @"5c13e1fdd1007229121176ec372e5d9cda2698f37f243a3965c1176bce1ecd01";
NSString *kClientSecret = @"40dfdc7edad96c219a8c948c228eda262a561774be74b8fc0996d9e57f62b771";
NSURL *baseURL = [NSURL URLWithString:@"http://localhost:5100"];
AFOAuth2Manager *OAuth2Manager =
@ennioma
ennioma / iBeaconAdvertising
Created June 10, 2014 08:25
Turn On iBeacon Advertising
- (void)advertise
{
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:kSomeUUID major:1 minor:1 identifier:kSomeId];
NSDictionary *beaconPeripheralData = [region peripheralDataWithMeasuredPower:nil];
[self.peripheralManager startAdvertising:beaconPeripheralData];
NSLog(@"Advertising on for the region: %@.", region);
}