Skip to content

Commit

Permalink
Update the sample to use the latest release of the CIQ Companion app …
Browse files Browse the repository at this point in the history
…SDK version 1.6.0

Updated to use the latest release of the SDK which includes changes to support Universal Links to launch the companion app when fetching paired devices from the Garmin Connect app.
Companion app now can send transient messages using the sendMessage() API.
  • Loading branch information
abhishekthakurGarmin committed Jan 17, 2025
1 parent 7108d59 commit 9796054
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 12 deletions.
15 changes: 9 additions & 6 deletions ExampleApp/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -66,6 +66,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
95121AC72CCA97E000DA53EC /* ExampleApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ExampleApp.entitlements; sourceTree = "<group>"; };
D6054E271A64792F0029113F /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
D6054E281A64792F0029113F /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
D60D04A8199E546C00870EDC /* ExampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -216,6 +217,7 @@
D60D04B1199E546C00870EDC /* ExampleApp */ = {
isa = PBXGroup;
children = (
95121AC72CCA97E000DA53EC /* ExampleApp.entitlements */,
D60D04BA199E546C00870EDC /* AppDelegate.h */,
D60D04BB199E546C00870EDC /* AppDelegate.m */,
D65B41A919F98B4800D9E655 /* Constants.h */,
Expand Down Expand Up @@ -361,9 +363,6 @@
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = Garmin;
TargetAttributes = {
D60D04A7199E546C00870EDC = {
DevelopmentTeam = 72ES32VZUA;
};
D60D04C8199E546D00870EDC = {
TestTargetID = D60D04A7199E546C00870EDC;
};
Expand Down Expand Up @@ -661,8 +660,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ExampleApp/ExampleApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/..",
Expand All @@ -676,7 +677,7 @@
"@executable_path/Frameworks",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.garmin.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.garmin.connectiqsdk.ExampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app;
Expand All @@ -687,8 +688,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ExampleApp/ExampleApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/..",
Expand All @@ -702,7 +705,7 @@
"@executable_path/Frameworks",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.garmin.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.garmin.connectiqsdk.ExampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"originHash" : "8546cec043655f015797511747e9dcac32fc6a266541bb73e85a63ae4956b656",
"pins" : [
{
"identity" : "connectiq-companion-app-sdk-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/garmin/connectiq-companion-app-sdk-ios",
"state" : {
"revision" : "d61f5b7ddb93c20a2ee2dfc67aea91fe21b66da1",
"version" : "1.5.2"
"revision" : "3312f9f50e3103e54c2c9b09b823f40a16e0c6cb",
"version" : "1.6.0"
}
}
],
"version" : 2
"version" : 3
}
14 changes: 13 additions & 1 deletion ExampleApp/ExampleApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Mobile is not installed, pass an instance of IQUIOverrideDelegate to this
// method(such as self in this example). You can then bypass the alert dialog
// or provide your own.
[[ConnectIQ sharedInstance] initializeWithUrlScheme:ReturnURLScheme uiOverrideDelegate:nil];
// Using URL Scheme
//[[ConnectIQ sharedInstance] initializeWithUrlScheme:ReturnURLScheme uiOverrideDelegate:nil];
// Using Universal links
[[ConnectIQ sharedInstance] initializeWithUniversalLinks:ReturnURLHost uiOverrideDelegate:nil];
[[DeviceManager sharedManager] restoreDevicesFromFileSystem];

// Override point for customization after application launch.
Expand Down Expand Up @@ -57,12 +60,21 @@ - (void)applicationWillTerminate:(UIApplication *)application {
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
// Handle Garmin Connect app attempting to launch this companion app using URL scheme
NSString* sourceApp = options[UIApplicationOpenURLOptionsSourceApplicationKey];
NSLog(@"Received URL from '%@': %@", sourceApp, url);

return [[DeviceManager sharedManager] handleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
// Handle Garmin Connect app attempting to launch this companion app using universal link
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
return [[DeviceManager sharedManager] handleOpenURL:userActivity.webpageURL];
}
return NO;
}

- (void)needsToInstallConnectMobile {
// If you set self as the UI override delegate in the SDK's initialize method,
// this method will be called if the SDK needs to install GCM. In this example,
Expand Down
2 changes: 1 addition & 1 deletion ExampleApp/ExampleApp/AppMessageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ - (void)sendMessage:(id)message {
LogMessage(@"%02.2f%% - %u/%u", percent, sentBytes, totalBytes);
} completion:^(IQSendMessageResult result) {
LogMessage(@"Send message finished with result %@", NSStringFromSendMessageResult(result));
}];
} isTransient:(false)];
}

- (void)logMessage:(NSString *)message {
Expand Down
1 change: 1 addition & 0 deletions ExampleApp/ExampleApp/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
#import <Foundation/Foundation.h>

extern NSString * const ReturnURLScheme;
extern NSString * const ReturnURLHost;
1 change: 1 addition & 0 deletions ExampleApp/ExampleApp/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
#import "Constants.h"

NSString * const ReturnURLScheme = @"exapp-123456";
NSString * const ReturnURLHost = @"connect.garmin.com/devices-list";
2 changes: 1 addition & 1 deletion ExampleApp/ExampleApp/DeviceManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (instancetype)initPrivate {
// --------------------------------------------------------------------------------

- (BOOL)handleOpenURL:(NSURL *)url {
if ([url.scheme isEqualToString:ReturnURLScheme]) {
if ([url.scheme isEqualToString:ReturnURLScheme] || [url.scheme isEqualToString:@"https"]) {
NSArray *devices = [[ConnectIQ sharedInstance] parseDeviceSelectionResponseFromURL:url];
if (devices != nil) {
NSLog(@"Forgetting %d known devices.", (int)self.devices.count);
Expand Down
10 changes: 10 additions & 0 deletions ExampleApp/ExampleApp/ExampleApp.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:connect.garmin.com</string>
</array>
</dict>
</plist>

0 comments on commit 9796054

Please sign in to comment.