Skip to content

Instantly share code, notes, and snippets.

View ranmyfriend's full-sized avatar
🦆
Calm

Ranjith ranmyfriend

🦆
Calm
View GitHub Profile
@ranmyfriend
ranmyfriend / DeviceInfo.swift
Created February 2, 2018 08:33
Attaching Device and App info on Email Body
fileprivate func showContactEmail() {
if MFMailComposeViewController.canSendMail() {
HSAnalytics.setEventForTypes(withLog: HSA.hamburgerContact)
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients([AppCons.CONTACTUS])
let iOSVersion = HSUtility.getAppVersion()
mailComposerVC.setSubject(AppCons.AppName+" iOS Client Support")
let systemVersion = UIDevice.current.systemVersion
let model = UIDevice.current.modelName
@ranmyfriend
ranmyfriend / RoundedView.swift
Created December 5, 2017 01:04
Rounded ImgeView with nice borderline
//
// RoundedView.swift
// RoundedImageView
//
// Created by Ranjith Kumar on 12/5/17.
// Copyright © 2017 Dash. All rights reserved.
//
import Foundation
import UIKit
@ranmyfriend
ranmyfriend / UIBinding.Swift
Created October 6, 2017 06:44
Centralized the UIBinding for common variables.
import UIKit
class User {
var name = ""
}
protocol UserBindable: AnyObject {
var user: User?{get set}
var nameLabel: UILabel!{get}
@ranmyfriend
ranmyfriend / FirebaseEnvironments.Swift
Last active October 3, 2017 09:12
Here you can load different set of environment variables for the staging and production environment
var envName:String = ""
#if Handstand || HandstandLiveDev
envName = "Handstand-GoogleService-Info"
#elseif HandstandStage
envName = "Handstand-Dev-GoogleService-Info"
#endif
let filePath = Bundle.main.path(forResource: envName, ofType: "plist")
FirebaseApp.configure(options: FirebaseOptions.init(contentsOfFile: filePath!)!)
@ranmyfriend
ranmyfriend / In App Purchase Receipt Validation code
Created August 29, 2017 06:59
If you want to check whether you are passing correct certificate or not? Why correct Certificate, Coz sometime you may get expired or invalid certificate. So from backend simply throws in some logical error. But don't panic and simply check from your end. Try to use it on Postman.
curl -X POST \
https://sandbox.itunes.apple.com/verifyReceipt \
-H 'cache-control: no-cache' \
-H 'postman-token: e3a85b2f-7906-1356-0711-ca248268d870' \
-d '{"receipt-data":"Your receipt data","password":"Your App-Specific Shared Secret"}'
import UIKit
import Foundation
enum PostType {
case text(text:String)
case image(image:UIImage)
case video(url:URL,duration:TimeInterval)
}
struct Post {
@ranmyfriend
ranmyfriend / KeyAsGeneric.Swift
Last active April 11, 2017 15:02
Here you can create a Dictionary key can hold any kind of object or value or enum. Here, DataSourceType.dictionary key is Generic.
import UIKit
import Foundation
enum Gender:Int {
case male,female,other
}
class Department:Hashable,Equatable{
var uid: Int
var hashValue: Int {
@ranmyfriend
ranmyfriend / Social Manager.Swift
Created April 8, 2017 08:43
How to handle different Social Logins using Manager class.
import UIKit
struct SocialManger {
static func fb()->FaceBook{
return FaceBook.shared
}
static func twitter()->Twitter{
return Twitter.shared
@ranmyfriend
ranmyfriend / Contacts_Integration.Swift
Created March 11, 2017 20:22
AddressBook Integration using CNContactStore in Swift 3
//
// AddressBookHelper.swift
// AddressBook
//
// Created by Ranjith Kumar on 11/03/2017.
// Copyright © 2017 F22Labs. All rights reserved.
//
import Foundation
import Contacts
@ranmyfriend
ranmyfriend / One Time Password View.swift
Created March 10, 2017 22:46
Phone Number - OneTimePassword Inputview design code and the fancy here is cursor going forward and backward is awesome.
import UIKit
protocol OTPInputViewProtocol:class {
func digitsInputViewCompletion()
}
fileprivate let MAX_COUNT_DOWN_TIME:Int = 120
class ADOTPInputView: UIView,UITextFieldDelegate {