Skip to content

Commit

Permalink
register with server for notificaiton after receiving the first devic…
Browse files Browse the repository at this point in the history
…e token only #91
  • Loading branch information
roznet committed Jun 8, 2021
1 parent d028d2d commit b7cab0c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion ConnectStats/src/GCAppDelegate+Swift.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ -(void)application:(UIApplication *)application didRegisterForRemoteNotification
[[GCAppGlobal profile] configSet:CONFIG_NOTIFICATION_DEVICE_TOKEN stringVal:token];
dispatch_async(dispatch_get_main_queue(), ^(){
[GCAppGlobal saveSettings];
GCConnectStatsRequestRegisterNotifications * req = RZReturnAutorelease([[GCConnectStatsRequestRegisterNotifications alloc] init]);
[[GCAppGlobal web] addRequest:req];
});

}else{
RZLog(RZLogInfo,@"remote notification registered with same token: %@", token);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class GCConnectStatsRequestRegisterNotifications : GCConnectStatsRequest {
if setting.authorizationStatus == .authorized {
DispatchQueue.main.async {
RZSLog.info("Push notification granted, registering")
// This will call didregister on app delegate and create a request if the token changed
UIApplication.shared.registerForRemoteNotifications()
GCAppGlobal.web().add(GCConnectStatsRequestRegisterNotifications())
}
}else{
RZSLog.info("Push notification not authorized, disabling")
Expand Down
6 changes: 1 addition & 5 deletions ConnectStats/src/GCGarminActivityLapsParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ -(GCGarminActivityLapsParser*)initWithData:(NSData *)jsonData forActivity:(GCAct
NSMutableArray * swimPoints = nil;

NSUInteger lapIdx = 0;

GCTrackPoint * last = nil;

for (NSDictionary * one in foundLaps) {
if([one isKindOfClass:[NSDictionary class]]){
Expand All @@ -88,9 +86,7 @@ -(GCGarminActivityLapsParser*)initWithData:(NSData *)jsonData forActivity:(GCAct
GCTrackPoint * swim = [[GCTrackPoint alloc] initWithDictionary:length forActivity:act];
swim.lapIndex = lapIdx;
[swimPoints addObject:swim];
[swim release];

last = swim;
[swim release];
}
}
[lapsSwim addObject:lap];
Expand Down
2 changes: 1 addition & 1 deletion ConnectStatsTests/GCTestsActivities.m
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ -(void)testActivityCalculated{
NSMutableDictionary<GCField*,GCNumberWithUnit*>*tmp = [NSMutableDictionary dictionary];
for (GCField*field in act.allFields) {
if( field.isCalculatedField ){
tmp[field] = [act numberWithUnitForField:field];
tmp[field] = [[act numberWithUnitForField:field] ;
}
}
NSDictionary<GCField*,GCActivityCalculatedValue*>*calculated = [NSDictionary dictionaryWithDictionary:tmp];
Expand Down
2 changes: 1 addition & 1 deletion connectstatstestapp/ConnectStatsTestApp-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
#import "GCGarminLoginSSORequest.h"
#import "GCConnectStatsRequest.h"
#import "GCConnectStatsSearchJsonParser.h"

#import "GCConnectStatsRequestFitFile.h"

0 comments on commit b7cab0c

Please sign in to comment.