This example demonstrates about How to create android app in facebook We need to create Facebook App on Facebook developer site to get Facebook App ID. Please follow the following steps one by one. Go to https://developers.facebook.com/ and add new app.Step 1 - Enter you app name and email in given fieldsStep 2 – Add below line build.gradle/mavenDownload the SDK from the Maven Central Repository:buildscript { repositories { mavenCentral()}}Compile the latest version of the SDK:dependencies { implementation 'com.facebook.android:facebook-android-sdk:[5, 6)' }Step 3 - Add Your Development and Release Key HashesGenerating a Development Key HashMac OS:- Execute below command in terminal ... Read More
In this post we will learn how to take screen shot programmatically in iOS.We will add on textField where we will change the value, take the screen shot by press of a button and then show the screen shot in an imageView which we will place just below the button itself.Remember that you can add this functionality on long press or any other gesture, and even save the image if you want. But right now we will just focus on capturing the screen shot and showing it on an image view.So let’s get startedStep 1 − Open Xcode → New ... Read More
In this post we will learn how to repeat a task after a regular interval.In this example we will update a label after a particular interval of time repeatedly.In iOS we user Timer to achieve this task. Lets get startedStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “Timer”Step 2 − Open Main.storyboard and add a label as shown below.Step 3 − Attach one @IBOutlet for the bottom label. Name it timerLabelStep 4 − We will show the seconds since when the app is launched on the label. So, declare two variables in ... Read More
In this post we will learn how to load PDF in UIWebView.Loading PDF in WebView is simple. Just follow the following steps.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “PDFInWebView”Step 2 − Open Main.storyboard and add UIWebView as shown belowStep 3 − Create @IBOutlet for the UIWebView, name it webview.Step 4 − Add as sample PDF project. We will load this PDF in webivew. I am adding a PDF file named sample PDF.Step 5 − Add the following lines in viewDidLoad method of ViewControllerif let pdf = Bundle.main.url(forResource: "sample", withExtension: "pdf", subdirectory: ... Read More
In this post we will learn how to open website in iOS browser.We will open Facebook in iOS browser.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “OpenBrowser”Step 2 − Open Main.storyboard and add a button as shown below. I have given the button title as “Open Facebook”Step 3 − Attach one @IBAction function in ViewController, name it openBrowserStep 4 − In openBrowserFunction write the code to open URL like shown below@IBAction func openBrowsere(_ sender: Any) { let url = URL(string: "https://www.facebook.com")! if UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url, options: [:], ... Read More
In this post we will learn how to open app store from iOS application.In this example we will open app store and show Facebook app on store. You can open your app if you want just by changing the ID to your app id.Lets do it.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “OpenAppStore”Step 2 − Open Main.storyboard and add a button as shown below.Step 3 − Attach one @IBAction for the button for click event. Name the function as openAppstoreClicked.Step 4 − In openAppstoreClicked we will write the code to open ... Read More
In this post we will be seeing how to make phone in iOS programmatically.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “MakeCall”Step 2 − Open Main.storyboard and add one text field and one button as shown belowStep 3 − Create @IBOutlet for the text field, name it phoneNumberTextfield.Step 4 − Create @IBAction method callButtonClicked for call buttonStep 5 − To make a call we can use iOS openURL. In callButtonClicked add following linesif let url = URL(string: "tel://\(phoneNumberTextfield.text!)"), UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url, options: [:], completionHandler: nil)Step 6 − Run the ... Read More
In this post we will learn how to fetch and show the iOS build and version numberStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “ShowBuildAndVersion”Step 2 − Open Main.storyboard and add two labels as shown below.Step 3 − Attach @IBOutLets for the two labels@IBOutlet weak var buildLabel: UILabel! @IBOutlet weak var versionLabel: UILabel!Step 4 − Change the build and version from project settings.Step 5 − In viewDidLoad of ViewController get the build and version number for infoDictionary of main bundle. Show it on the corresponding labels.override func viewDidLoad() { super.viewDidLoad() ... Read More
In this post we will be seeing how to get the touch position on device using Swift.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “TouchMe”Step 2 − Open Main.storyboard and add one label as shown below. On this label we will show the touch position.Step 3 − Create @IBOutlet for the label, name it touchPositionLabel.Step 4 − We will be overriding the touchesBegan method in ViewController to get the touch position in the view. Override the method as shown belowoverride func touchesBegan(_ touches: Set, with event: UIEvent?) { ... Read More
In this post we will be seeing how to get the battery state in iOS.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “BatteryState”Step 2 − Open Main.storyboard and add two label as shown below. On this label we will show battery status.Step 3 − Enable the battery state monitoring, using the following code. You can put this code in viewDidLoad of ViewControllerUIDevice.current.isBatteryMonitoringEnabled = trueStep 4 − Declare a variable to hold the battery state. We will name this variable batteryState. From this variable we are returning UIDevice.current.batteryState, that would ... Read More