Skip to content

Commit

Permalink
Generated Docs for "Update README.md (#105)* Update README.md* Update…
Browse files Browse the repository at this point in the history
… README.md" (#107)

* Link to license file in README (#60)

Co-authored-by: Evan Masseau <>

* Updated readme to include troubleshooting steps when running pod install (#63)

updated readme

* Updating version to 0.1.1 (#66)

* 0.1.1

* updating version

* reverting back to use older rn version

* updating yarn lock

* removing changes to package lock file

* Fixes for React Native Apps <= 0.72.0 (#71)

* Fix the react-native gradle dependency
* Add a local property to enable specifying react-native version for the SDK for local development
* Specify Kotlin version that is compatible with Android SDK's (although this didn't seem to actually cause any build errors)
* Remove accidental use of an extension method that is technically SDK 24+

---------

Co-authored-by: Evan Masseau <>

* Update local.properties template files (#68)

* Add template local.properties file to example app
* Be clearer about VCS status of these files.

---------

Co-authored-by: Evan Masseau <>

* Bump example iOS project lockfile (#74)

I think this needs to be bumped when we increase the overall project version.

Co-authored-by: Evan Masseau <>

* Github CI Updates (#75)

* Move doc bot to its own file so we don't have to see it as skipped all the time.

* Use same ruby version as local dev environment

* Stop using `yarn pod-install` because it creates an erroneous xcode.env.local file that breaks the hermes build scripts.

---------

Co-authored-by: Evan Masseau <>

* Updating to iOS SDK 3.0.2 (#77)

* 0.1.1

* updated to us latest iOS SDK

* removing package lock

* Pod install | static linking issue | RCT Folly | Turbo modules (#70)

* 0.1.1

* removed turbo module stuff and added xcconfig

* removing package lock

* comitting example app pod lock file

---------

Co-authored-by: Evan Masseau <>
Co-authored-by: Evan C Masseau <[email protected]>

* Readme rewrite with references to native SDKs and Klaviyo help center (#62)


---------

Co-authored-by: Evan Masseau <>
Co-authored-by: Kenny Tsui <[email protected]>

* Release 0.1.2  (#84)

* 0.1.1

* Release 0.1.2

* removed package lock

* podlock file changes

* Break up CI files so we can get individual badges (#86)

* Break up CI files so we can get individual badges

* Add badges and fix names

---------

Co-authored-by: Evan Masseau <>

* Add action to publish to NPM after publishing a release (#82)


---------

Co-authored-by: Evan Masseau <>

* Update README.md (#90)

* Publish to NPM with the default npm registry configured in package.json (#92)


---------

Co-authored-by: Evan Masseau <>

* Updated iOS instructions in example app (#99)

* 0.1.1

* udpate the example app to implement push

* hanlded deep links

* removed package json lock file

* updated to addressed Evan comments in the pr

* Fix mistaken duplicate open push section (#95)

Co-authored-by: Evan Masseau <>

* Remove local.properties from git index (#96)

* remove local.properties from git index, changes were still being tracked despite gitignore

* missed variable

---------

Co-authored-by: Evan Masseau <>

* Update README.md (#105)

* Update README.md

* Update README.md

* Implemented deep links to call react native in example iOS app (#104)

* 0.1.1

* implemented deep linking calls to react native

* removed unused method

* removed package lock

* added deep linking hanlder

* Generated docs for 815a893

---------

Co-authored-by: Evan C Masseau <[email protected]>
Co-authored-by: Ajay Subramanya <[email protected]>
Co-authored-by: Kenny Tsui <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
5 people authored Feb 16, 2024
1 parent be56023 commit 9e8c460
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 95 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,17 @@ instructions below.
- [Android](https://github.com/klaviyo/klaviyo-android-sdk#Deep-Linking) instructions for handling intent filters
- [iOS](https://github.com/klaviyo/klaviyo-swift-sdk#Deep-Linking)
As shown in the native SDK documentation, you can follow option 1 or 2.
With option 1, when you get the callback, you can handle it as follows:

With option 1, when you handle the open url (in [`application(_:open:options)`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application)),
you call the linking code block above similar to what you would do with option 1.

With option 2, when you get the `deepLinkHandler`, you can handle it as follows:

```objective-c
[RCTLinkingManager application:application openURL:url options:options]
[RCTLinkingManager application:UIApplication.sharedApplication openURL: url options: @{}];
```

Since you won't have `options`, you can just pass in an empty dictionary for that parameter.
With option 2, when you handle the open url (in [`application(_:open:options)`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application)),
you call the linking code block above similar to what you would do with option 1.
For application, you can pass in an instance of `UIApplication` and since you won't have `options`, you can just pass in an empty dictionary for that parameter.
In your React Native code, you can handle the deep link as follows:
Expand Down
10 changes: 5 additions & 5 deletions docs/enums/EventName.html

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions docs/enums/ProfileProperty.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@
<li><p><a href="https://github.com/klaviyo/klaviyo-android-sdk#Deep-Linking">Android</a> instructions for handling intent filters</p>
</li>
<li><p><a href="https://github.com/klaviyo/klaviyo-swift-sdk#Deep-Linking">iOS</a>
As shown in the native SDK documentation, you can follow option 1 or 2.
With option 1, when you get the callback, you can handle it as follows:</p>
<pre><code class="language-objective-c"><span class="hl-2">[RCTLinkingManager </span><span class="hl-1">application:</span><span class="hl-2">application </span><span class="hl-1">openURL:</span><span class="hl-2">url </span><span class="hl-1">options:</span><span class="hl-2">options]</span>
</code><button>Copy</button></pre>
<p>Since you won&#39;t have <code>options</code>, you can just pass in an empty dictionary for that parameter.</p>
<p>With option 2, when you handle the open url (in <a href="https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application"><code>application(_:open:options)</code></a>),
As shown in the native SDK documentation, you can follow option 1 or 2.</p>
<p>With option 1, when you handle the open url (in <a href="https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application"><code>application(_:open:options)</code></a>),
you call the linking code block above similar to what you would do with option 1.</p>
<p>With option 2, when you get the <code>deepLinkHandler</code>, you can handle it as follows:</p>
<pre><code class="language-objective-c"><span class="hl-2"> [RCTLinkingManager </span><span class="hl-1">application:</span><span class="hl-2">UIApplication.sharedApplication </span><span class="hl-1">openURL:</span><span class="hl-2"> url </span><span class="hl-1">options:</span><span class="hl-2"> @{}];</span>
</code><button>Copy</button></pre>
<p>For application, you can pass in an instance of <code>UIApplication</code> and since you won&#39;t have <code>options</code>, you can just pass in an empty dictionary for that parameter.</p>
</li>
</ul>
<p>In your React Native code, you can handle the deep link as follows:</p>
Expand Down
10 changes: 5 additions & 5 deletions docs/interfaces/Event.html

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions docs/interfaces/KlaviyoInterface.html

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/interfaces/Location.html

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions docs/interfaces/Profile.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/EventProperties.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/ProfileProperties.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/ProfilePropertyKey.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/variables/Klaviyo.html

Large diffs are not rendered by default.

29 changes: 25 additions & 4 deletions example/ios/KlaviyoReactNativeSdkExample/AppDelegate.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>


@implementation AppDelegate

Expand Down Expand Up @@ -31,9 +33,8 @@ - (void)application:(UIApplication *)application didRegisterForRemoteNotificatio
[PushNotificationsHelper setPushTokenWithToken:deviceToken];

if (isDebug) {
NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"Device Token: %@", token);
NSString *token = [self stringFromDeviceToken:deviceToken];
NSLog(@"Device Token: %@", token);
}
}

Expand All @@ -50,7 +51,11 @@ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotif
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
// Installation Step 10: call `handleReceivingPushWithResponse` method and pass in the below arguments. Note that handleReceivingPushWithResponse calls our SDK and is
// something that has to be implemented in your app as well.
[PushNotificationsHelper handleReceivingPushWithResponse:response completionHandler:completionHandler];
// furthur, if you want to intercept urls instead of them being routed to the system and system calling `application:openURL:options:` you can implement the `deepLinkHandler` below
[PushNotificationsHelper handleReceivingPushWithResponse:response completionHandler:completionHandler deepLinkHandler:^(NSURL * _Nonnull url) {
NSLog(@"URL is %@", url);
[RCTLinkingManager application:UIApplication.sharedApplication openURL: url options: @{}];
}];

if (isDebug) {
UIAlertController *alert = [UIAlertController
Expand Down Expand Up @@ -88,6 +93,13 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
}

// Installation Step 13: Implement this method to receive deep link. There are some addition setup steps needed as mentioned in the readme here -
// https://github.com/klaviyo/klaviyo-swift-sdk?tab=readme-ov-file#deep-linking
// Calling `RCTLinkingManager` is required for your react native listeners to be called
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [RCTLinkingManager application:app openURL:url options:options];
}

// Installation Step 13: Implement this method to receive deep link. There are some addition setup steps needed as mentioned in the readme here -
// https://github.com/klaviyo/klaviyo-swift-sdk?tab=readme-ov-file#deep-linking
// additionally routing to the right screen in the app based on the url is also something that should be handled
Expand All @@ -110,4 +122,13 @@ - (NSURL *)getBundleURL
#endif
}

- (NSString *)stringFromDeviceToken:(NSData *)deviceToken {
const unsigned char *tokenBytes = (const unsigned char *)[deviceToken bytes];
NSMutableString *token = [NSMutableString stringWithCapacity:([deviceToken length] * 2)];
for (NSUInteger i = 0; i < [deviceToken length]; i++) {
[token appendFormat:@"%02x", tokenBytes[i]];
}
return token;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,18 @@ class PushNotificationsHelper: NSObject {
}

@objc
static func handleReceivingPush(response: UNNotificationResponse, completionHandler: @escaping () -> Void ) {
let handled = KlaviyoSDK().handle(notificationResponse: response, withCompletionHandler: completionHandler)
static func handleReceivingPush(
response: UNNotificationResponse,
completionHandler: @escaping () -> Void,
deepLinkHandler: ((URL) -> Void)? = nil
) {
let handled = KlaviyoSDK().handle(
notificationResponse: response,
withCompletionHandler: completionHandler,
deepLinkHandler: deepLinkHandler
)
if !handled {
completionHandler()
}
}

@objc
static func handleDeepLinks(url: URL) -> Bool {
guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true)
else {
print("Invalid deep linking URL")
return false
}
print("components: \(components.debugDescription)")
return true
}
}
12 changes: 12 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import * as React from 'react';

import { useEffect } from 'react';

import { Button, View } from 'react-native';
import { type AppViewInterface, appViews } from './AppViewInterface';
import { styles } from './Styles';
import { Linking } from 'react-native';

export default function App() {
useEffect(() => {
Linking.addEventListener('url', ({ url }) => {
console.log('Event Listener: url', url);
});
Linking.getInitialURL().then((url) => {
console.log('Initial Url: url', url);
});
}, []);

return (
<View style={styles.container}>
<>
Expand Down

0 comments on commit 9e8c460

Please sign in to comment.