Created
February 26, 2016 19:02
-
-
Save MarkVillacampa/12033317b604a950937a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:options) | |
if options && options[UIApplicationLaunchOptionsRemoteNotificationKey] | |
# The application was completely closed and the user launched it by tapping on a notification | |
else | |
# The application was completely closed and the user launched it by tapping on the app's icon | |
end | |
end | |
def application(application, didReceiveRemoteNotification:notification) | |
if application.applicationState != UIApplicationStateActive | |
# The application received a notification while it was inactive. | |
# The app can be inactive because it was in the background and is in the process of being foregrounded, | |
# or because the user opened the notification center, or the control center, or is in a call over our | |
# application. | |
# To check if the application is inactive because it is in the process of being foregorunded, | |
# we store the time of the last call to "applicationWillEnterForeground" and check if it was | |
# less than 1 second ago. | |
return if @last_foregrounding.nil? || NSDate.date.timeIntervalSinceDate(@last_foregrounding) > 1 | |
Router.handle_notification(notification) | |
end | |
end | |
def applicationWillEnterForeground(application) | |
@last_foregrounding = NSDate.date | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment