Skip to content

Commit 5b5eab3

Browse files
niallzatoNiall Brennanmarkzegarelli
authored
Add platform code for setting writekey (#4050)
* add platform code * add platform code * Update src/connections/sources/catalog/libraries/mobile/react-native/index.md Co-authored-by: markzegarelli <[email protected]> * Update src/connections/sources/catalog/libraries/mobile/react-native/index.md Co-authored-by: markzegarelli <[email protected]> Co-authored-by: Niall Brennan <[email protected]> Co-authored-by: markzegarelli <[email protected]>
1 parent ba32fcb commit 5b5eab3

File tree

1 file changed

+13
-1
lines changed
  • src/connections/sources/catalog/libraries/mobile/react-native

1 file changed

+13
-1
lines changed

src/connections/sources/catalog/libraries/mobile/react-native/index.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,19 @@ No, only the plugins listed above are supported in device-mode for Analytics Rea
595595
### Will I still see device-mode integrations listed as `false` in the integrations object?
596596
When you successfully package a plugin in device-mode, you won't see the integration listed as `false` in the integrations object for a Segment event. This logic is packaged in the event metadata, and isn't surfaced in the Segment debugger.
597597
### Why are my IDs not set in UUID format?
598-
Due to [limitations](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/uuid.ts#L5){:target="_blank"} with the React Native bridge, Segment doesn't use UUID format for `anonymousId`s and `messageId`s in local development. These IDs will be set in UUID format for your live app.
598+
Due to [limitations](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/uuid.ts#L5){:target="_blank"} with the React Native bridge, Segment doesn't use UUID format for `anonymousId` and `messageId` values in local development. These IDs will be set in UUID format for your live app.
599+
### How do I set a distinct writeKey for iOS and android?
600+
You can set different writeKeys for iOS and Android. This is helpful if you want to send data to different destinations based on the client side platform. To set different writeKeys, you can dynamically set the writeKey when you initialize the Segment client:
599601
602+
```js
603+
import {Platform} from 'react-native';
604+
import { createClient } from '@segment/analytics-react-native';
605+
606+
const segmentWriteKey = Platform.iOS ? 'ios-writekey' : 'android-writekey';
607+
608+
const segmentClient = createClient({
609+
writeKey: segmentWriteKey
610+
});
611+
```
600612
## Changelog
601613
[View the Analytics React Native 2.0 changelog on GitHub](https://github.com/segmentio/analytics-react-native/releases){:target="_blank"}.

0 commit comments

Comments
 (0)