This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func saveLogin(password: NSData, userName:String, service:String) | |
{ | |
//Create the query | |
let keychainQuery: NSMutableDictionary = NSMutableDictionary(objects: [kSecClassGenericPasswordValue, service, userName, password], forKeys: [kSecClassValue, kSecAttrServiceValue, kSecAttrAccountValue, kSecValueDataValue]) | |
// Delete any existing items | |
SecItemDelete(keychainQuery as CFDictionaryRef) | |
//Add the query to the keychain | |
let status: OSStatus = SecItemAdd(keychainQuery as CFDictionaryRef, nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func load(service: NSString, userName:String) -> NSString? | |
{ | |
//Create the query keychain | |
let keychainQuery: NSMutableDictionary = NSMutableDictionary(objects: [kSecClassGenericPasswordValue, service, userName, kCFBooleanTrue, kSecMatchLimitOneValue], forKeys: [kSecClassValue, kSecAttrServiceValue, kSecAttrAccountValue, kSecReturnDataValue, kSecMatchLimitValue]) | |
var dataTypeRef : Unmanaged<AnyObject>? | |
// Search for the keychain items | |
let status: OSStatus = withUnsafeMutablePointer(&dataTypeRef) { SecItemCopyMatching(keychainQuery as CFDictionaryRef, UnsafeMutablePointer($0)) } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get the Path to the receipt | |
let receiptUrl = Bundle.main.appStoreReceiptURL //Swift2 : NSBundle.mainBundle().appStoreReceiptURL | |
//Check if it's actually there | |
if FileManager.default.fileExists(atPath: receiptUrl!.path) //Swift 2: NSFileManager.defaultManager().fileExistsAtPath(receiptUrl!.path!) | |
{ | |
//Load in the receipt | |
//Swift 2: let receipt: NSData = try! NSData(contentsOfURL:receiptUrl!, options: []) | |
//Swift 3 | |
let receipt: Data = try! Data(contentsOf: receiptUrl!, options: []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Swift 2 | |
//let octets = pkcs7_d_data(pkcs7_d_sign(receiptPKCS7).memory.contents) | |
//var ptr = UnsafePointer<UInt8>(octets.memory.data) | |
//let end = ptr.advancedBy(Int(octets.memory.length)) | |
//Swift 3 | |
let octets = pkcs7_d_data(pkcs7_d_sign(receiptPKCS7).pointee.contents) | |
var ptr = UnsafePointer<UInt8>(octets?.pointee.data) | |
let end = ptr?.advanced(by: Int((octets?.pointee.length)!)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getProductIdFromReceipt(_ data:Data) -> String? //Swift 2: func getProductIdFromReceipt(data:NSData) -> String? | |
{ | |
//Swift 2: var p = UnsafePointer<UInt8>(data.bytes) | |
//Swift 3 | |
var p : UnsafePointer? = (data as NSData).bytes.bindMemory(to: UInt8.self, capacity: data.count) | |
let dataLength = data.length | |
var type:Int32 = 0 | |
var tag:Int32 = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
environment = Sandbox; | |
receipt = { | |
"adam_id" = 0; | |
"app_item_id" = 0; | |
"application_version" = 1; | |
"bundle_id" = "com.yourcompany.yourapp"; | |
"download_id" = 0; | |
"in_app" = ( | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Update () { | |
if (Input.touchCount == 1) { | |
//Get the player and camera objects | |
GameObject player = GameObject.FindGameObjectWithTag ("Player"); | |
GameObject camera = GameObject.FindGameObjectWithTag ("MainCamera"); | |
//Change the character's position by moving in the direction that the camera is facing | |
player.transform.position = player.transform.position + camera.transform.forward; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace CocosDemo | |
{ | |
public class App : Application | |
{ | |
static public int ScreenHeight; | |
static public int ScreenWidth; | |
public App () | |
{ | |
// The root page of your application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override bool FinishedLaunching (UIApplication app, NSDictionary options) | |
{ | |
global::Xamarin.Forms.Forms.Init (); | |
// Code for starting up the Xamarin Test Cloud Agent | |
#if ENABLE_TEST_CLOUD | |
Xamarin.Calabash.Start(); | |
#endif | |
App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height; | |
App.ScreenWidth = (int)UIScreen.MainScreen.Bounds.Width; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnCreate (Bundle bundle) | |
{ | |
base.OnCreate (bundle); | |
global::Xamarin.Forms.Forms.Init (this, bundle); | |
var metrics = Resources.DisplayMetrics; | |
var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); | |
var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); | |
App.ScreenWidth = metrics.WidthPixels; | |
App.ScreenHeight = metrics.HeightPixels; |
OlderNewer