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.

Read more

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.

Steps for implement code to handle push notifications in iOS 10

Import UserNotifications.framework in your AppDelegate file

Also add UNUserNotificationCenterDelegate.

Register for push notification

Before registration check the version of iOS and then based on versions do the code. For iOS 7 code was different, fro iOS 8 & 9 code was different and again for iOS 10 code is different.

As per my opinion you have to set the deployment target to iOS 8 or iOS 9 and later. For this you can check the adoption ratio of iOS in the devices.

Define constant for version check :

Add code in your did finish launching

Handling delegate methods for UserNotifications

You will be surprise that notification displayed when application in foreground too in iOS 10. As we know that in old versions we display alert or something else which will be look like notification comes in foreground.

There are two delegate methods need to be handled :

Add Push Notifications Entitlements

Go to your project target’s Capabilities tab and add Push Notifications Entitlements.

Push Notifications Entitlements

If it’s available in your certificates then it will enable directly else configure your profile with the certificates and you can enable this capability by that.

All Done!

Happy Coding ?

I have added sample code of objective-c on github with iOS 8, 9 and 10 support of push notification.
I have also posted about Push Notifications in iOS 10 [Swift].

iOS 10 New Frameworks

iOS10

  • CallKit
    The CallKit framework (CallKit.framework) lets VoIP apps integrate with the iPhone UI and give users a great experience. Use this framework to let users view and answer incoming VoIP calls on the lock screen and manage contacts from VoIP calls in the Phone app’s Favorites and Recents views.
  • Intents
    The Intents framework (Intents.framework) supports the handling of SiriKit interactions.
  • IntentsUI
    The Intents UI framework (IntentsUI.framework) supports the creation of an Intents UI extension, which is an optional app extension that displays custom content in the Siri or Maps interfaces.
  • Messages
    To develop an iMessage app, you use the APIs in the Messages framework (Messages.framework) and To create app extensions that interact with the Messages app, allowing users to send text, stickers, media files, and interactive messages.
  • Speech
    Using the APIs in the Speech framework (Speech.framework), you can perform speech transcription of both real-time and recorded audio.
  • UserNotifications
    User Notifications framework (UserNotifications.framework), which supports the delivery and handling of local and remote notifications.
  • UserNotificationsUI
    User Notifications UI framework (UserNotificationsUI.framework) lets you customize the appearance of local and remote notifications when they appear on the user’s device.
  • VideoSubscriberAccount
    Video Subscriber Account framework (VideoSubscriberAccount.framework) to help apps that support authenticated streaming or authenticated video on demand (also known as TV Everywhere) authenticate with their cable or satellite TV provider.

References :

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 🙂