ios - Reauthentication Code in App Delegate? -
so using cookie authentication. cookie expires after 1 hr. trying cover edge use case if user has app in active foreground more 1 hr straight, how refresh cookie. basically, need make login call token in background reauthenticate , refresh cookie before of network calls work again.
should putting reauthentication code inside app delegate since have multiple view controllers network calls? practice or should putting code in root view controller?
my idea 401 error code , nsnotification app delegate reauthenticate.
you can save timestamp (for example in nsuserdefaults
) when application resigns active (applicationwillresignactive:
), , calculate time difference when app active again (applicationdidbecomeactive:
). if time difference greater amount (say hour) should reauthenticate app , new cookie.
also 401 depended notification method useful, because server may return 401 other reasons.
Comments
Post a Comment