Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to a standard auth token creation interface #159

Merged
merged 2 commits into from
Aug 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
id="edu.berkeley.eecs.emission.cordova.datacollection"
version="1.0.2">
version="1.0.3">

<name>DataCollection</name>
<description>Background data collection FTW! This is the part that I really
Expand Down
7 changes: 3 additions & 4 deletions src/ios/BEMAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import "BEMServerSyncPlugin.h"
#import "Cordova/CDVConfigParser.h"
#import <objc/runtime.h>
#import "AuthCompletionHandler.h"
#import "AuthTokenCreationFactory.h"

@implementation AppDelegate (datacollection)

Expand Down Expand Up @@ -147,16 +147,15 @@ + (void) launchTripEndCheckAndRemoteSync:(void (^)(UIBackgroundFetchResult))comp
NSLog(@"About to check whether a trip has ended");
NSDictionary* localUserInfo = @{@"handler": completionHandler};

[[AuthCompletionHandler sharedInstance] getValidAuth:^(GIDGoogleUser *user, NSError *error) {
[[AuthTokenCreationFactory getInstance] getExpirationDate:^(NSString *expirationDate, NSError *error) {
/*
* Note that we do not condition any further tasks on this refresh. That is because, in general, we expect that
* the token refreshed at this time will be used to push the next set of values. This is just pre-emptive refreshing,
* to increase the chance that we will finish pushing our data within the 30 sec interval.
*/
if (error == NULL) {
GIDAuthentication* currAuth = user.authentication;
[LocalNotificationManager addNotification:[NSString stringWithFormat:
@"Finished refreshing token in background, new expiry is %@", currAuth.idTokenExpirationDate]
@"Finished refreshing token in background, new expiry is %@",expirationDate]
showUI:FALSE];
} else {
[LocalNotificationManager addNotification:[NSString stringWithFormat:
Expand Down
7 changes: 3 additions & 4 deletions src/ios/Location/TripDiaryStateMachine.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#import "LocationTrackingConfig.h"
#import "ConfigManager.h"
#import "AuthCompletionHandler.h"
#import "AuthTokenCreationFactory.h"
#import "DataUtils.h"

#import <CoreMotion/CoreMotion.h>
Expand Down Expand Up @@ -444,16 +444,15 @@ - (void) syncAndNotify

- (void) forceRefreshToken
{
[[AuthCompletionHandler sharedInstance] getValidAuth:^(GIDGoogleUser *user, NSError *error) {
[[AuthTokenCreationFactory getInstance] getExpirationDate:^(NSString *expirationDate, NSError *error) {
/*
* Note that we do not condition any further tasks on this refresh. That is because, in general, we expect that
* the token refreshed at this time will be used to push the next set of values. This is just pre-emptive refreshing,
* to increase the chance that we will finish pushing our data within the 30 sec interval.
*/
if (error == NULL) {
GIDAuthentication* currAuth = user.authentication;
[LocalNotificationManager addNotification:[NSString stringWithFormat:
@"Finished refreshing token in background, new expiry is %@", currAuth.idTokenExpirationDate]
@"Finished refreshing token in background, new expiry is %@", expirationDate]
showUI:FALSE];
} else {
[LocalNotificationManager addNotification:[NSString stringWithFormat:
Expand Down