Firebase Remote Config [Swift]

Firebase Remote Config is used to change the application behavior without publishing update of application.

Firebase Remote Config
Firebase Remote Config

Basic setup is to create project at firebase console.

Firebase Console
Firebase Console – Follow the steps to create a project

I am adding a video here to setup the firebase remote config.

[youtube https://www.youtube.com/watch?v=Sq6zV__NJek]

Add core firebase to your project

Follow the steps available at : Add Firebase to your iOS Project

Steps to add remote config to your app

  1. Installation

    Update your project with required cocoapods

    Run pod install from terminal and open the created .xcworkspace file.

  2. Configure Firebase Module

    Just import firebase module and apply configure method. It will configure by itself by using GoogleService-Info.plist.

  3. Configure remote config

    Create Remote Config object, as shown in the following example:

    Create an plist file for default values of configuration and set it to remote config:

    FireSwiftRemoteConfigDefaults.plist with sampleURL key:

    Use current default key from your defaults set on plist file and send fetch request in remote config to get the configuration keys set on the firebase console:

    Note : If in developer mode cacheExpiration is set to 0 so each fetch will retrieve values from the server. The default expiration duration is 43200 (12 hours).

  4. All Done.

    Sample code available at Github. There are many other things with firebase, I will try give update in next tutorials.

    If you like then Buy me a coffee ☕️

    Happy Coding 🙂

Push Notifications in iOS 10 [Swift]

Push Notification iOS 10 Swift
Push Notification iOS 10 Swift

The new framework called “UserNotifications” is introduced with iOS 10 SDK. The UserNotifications framework (UserNotifications.framework) supports the delivery and handling of local and remote notifications.

So, Let see what we have to change to get the push notifications in iOS 10.

Continue reading

Push Notifications in iOS 10 [Objective-C]

Push Notification iOS10
Push Notification iOS10

The new framework called “UserNotifications” is introduced with iOS 10 SDK. The UserNotifications framework (UserNotifications.framework) supports the delivery and handling of local and remote notifications.

So, Let see what we have to change to get the push notifications in iOS 10.

Continue reading

Get Reactions from Timeline Post via Facebook Graph API – Swift – iOS

Facebook Reactions
Facebook Reactions

New version of SDK is 4.16.x(Swift) and Graph API Version is 2.8.

With the Graph API 2.6 Facebook has given support to fetch (read only) the Reactions on Timeline Posts.

Post is updated for iOS 10 and Swift 3

API documentation is available here.

Let’s learn how to get reactions from the post

Install pods

Login with Facebook

I have already written a tutorial on Facebook Login.

Get Facebook Posts via Graph API

We can get the Facebook post via graph API : /me/posts for that we have to add user_posts permission with login.

Get Reactions from one of the Post

We can get the Facebook post reactions via graph API : /{post-id}/reactions. We have to pass parameters like fields and summary as described in getReactions function.

Note : Here I am writing sample for only first post.

Response should be like

Type of reactions : NONE, LIKE, LOVE, WOW, HAHA, SAD, ANGRY

#Like #Share #React 🙂 😛 😀

Happy coding 🙂

Swift 2.2 Warnings and It’s Solutions – Xcode 7.3

apple_swift_logo

Xcode 7.3 came with Swift 2.2 Version. I just updated to Xcode 7.3 and found following warnings because of Swift version change.

List of warnings with it’s solution:

  1. ‘var’ parameters are deprecated and will be removed in Swift 3
  2. Warning Function Var
    Warning Function Var

    Warning with:

    func functionTest(var param:String) {
    	print(param)
    }
    

    Solution:

    func functionTest(param:String) {
    	print(param)
    }
    

    If you want to update that variable inside the function then you have to create copy of that variable to do operations on that.

  3. Use of string literal for Objective-C selectors is deprecated; use ‘#selector’ instead
  4. Warning Selector
    Warning Selector

    Warning with:

    btn.addTarget(self, action: "functionName", forControlEvents: UIControlEvents.TouchUpInside)
    

    OR

    btn.addTarget(self, action: Selector("functionName"), forControlEvents: UIControlEvents.TouchUpInside)
    

    Solution:

    btn.addTarget(self, action: #selector(ViewController.functionName), forControlEvents: UIControlEvents.TouchUpInside)
    

    Apple Documentation : Added information about the #selector syntax for Objective-C selectors to the Selector Expression section.

  5. ‘++’ is deprecated: it will be removed in Swift 3
  6. Warning ++
    Warning ++

    Warning with:

    var i = 0
            
    for str in arrStr {
    	print(str)
    	i++
    }
    

    Solution:

    var i = 0
            
    for str in arrStr {
    	print(str)
    	i += 1
    }
    

    Apple Documentation : Removed discussion of C-style for loops, the ++ prefix and postfix operators, and the — prefix and postfix operators.

  7. C-style for statement is deprecated and will be removed in a future version of Swift
  8. Warning For Statement
    Warning For Statement

    Warning with:

    for var i=0; i<arrStr.count; i += 1 {
    	print(arrStr[i])
    }
    

    Solution:

    for i in 0 ..< arrStr.count {
    	print(arrStr[i])
    }
    

  9. __FILE__ is deprecated and will be removed in Swift 3, please use #file
  10. Warning __FILE__
    Warning __FILE__

    Warning with:

    __FILE__
    

    Solution:

    #file
    

More swift tutorials/articles are available here.

Happy Coding 🙂