Skip to content
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
23 changes: 0 additions & 23 deletions SampleApp/javascript/.eslintrc.js

This file was deleted.

8 changes: 4 additions & 4 deletions SampleApp/javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @format
*/

import { AppRegistry } from 'react-native'
import App from './js/App'
import { name as appName } from './app.json'
import {AppRegistry} from 'react-native';
import App from './js/App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App)
AppRegistry.registerComponent(appName, () => App);
17 changes: 9 additions & 8 deletions SampleApp/javascript/js/App.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'

import React from 'react';
interface Props {
}
export default class App extends React.Component {
constructor (props: Props)
render (): JSX.Element
private readonly homeTabRef
private readonly navigate
private readonly urlHandler
constructor(props: Props);
render(): JSX.Element;
private homeTabRef;
private navigate;
private urlHandler;
}
export {}
export {};
165 changes: 81 additions & 84 deletions SampleApp/javascript/js/App.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,97 @@
import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import Icon from 'react-native-vector-icons/Ionicons'
import HomeTab from './HomeTab'
import SettingsTab from './SettingsTab'
import { coffees } from './Data'

// Step 1:
// Import the Iterable and IterableConfig class.
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Icon from 'react-native-vector-icons/Ionicons';
import HomeTab from './HomeTab';
import SettingsTab from './SettingsTab';
import { coffees } from './Data';

// Step 1:
// Import the Iterable and IterableConfig class.
// Refer to "Installing Iterable's React Native SDK" of the developer guide.
// (https://support.iterable.com/hc/en-us/articles/360045714132-Installing-Iterable-s-React-Native-SDK-#step-5-import-iterable-sdk-classes-wherever-needed)

import { Iterable, IterableConfig } from '@iterable/react-native-sdk'
import { Iterable, IterableConfig, } from '@iterable/react-native-sdk';

// Step 2:
// Step 2:
// Create a Config.js and add your apiKey as "iterableAPIKey".
// Refer to "Creating API Keys" under "API Keys" of the developer guide
// Refer to "Creating API Keys" under "API Keys" of the developer guide
// to create an API key for your Iterable project.
// (https://support.iterable.com/hc/en-us/articles/360043464871#creating-api-keys)

import { iterableAPIKey } from './Config'
import { iterableAPIKey } from './Config';

export default class App extends React.Component {
constructor (props) {
super(props)

this.homeTabRef = React.createRef()

// Step 3: Initialize the React Native SDK here.
// Create an IterableConfig object with various properties set.
// The config object is used to customize various features of the SDK such as the URL handler and custom action handler.
// If a config object is not defined, the React Native SDK defaults to the default configuration.

// The IterableConfig.js file is linked to the documentation.
// Refer to Step 6 of "Installing Iterable's React Native SDK" of the developer guide.
// (https://support.iterable.com/hc/en-us/articles/360045714132-Installing-Iterable-s-React-Native-SDK-#step-6-initialize-iterable-s-react-native-sdk)

// Below is a sample implementation of the config object where we set the urlHAndler and inAppDisplayInterval

const config = new IterableConfig()

// inAppDisplayInterval sets the number of seconds to wait between displaying multiple in-app messages in sequence
config.inAppDisplayInterval = 1.0

// urlHandler is set up here to handle deep link URLs and in-app message buttons and link URLs
config.urlHandler = this.urlHandler
constructor(props) {
super(props);

this.homeTabRef = React.createRef();

// Step 3: Initialize the React Native SDK here.
// Create an IterableConfig object with various properties set.
// The config object is used to customize various features of the SDK such as the URL handler and custom action handler.
// If a config object is not defined, the React Native SDK defaults to the default configuration.

// The IterableConfig.js file is linked to the documentation.
// Refer to Step 6 of "Installing Iterable's React Native SDK" of the developer guide.
// (https://support.iterable.com/hc/en-us/articles/360045714132-Installing-Iterable-s-React-Native-SDK-#step-6-initialize-iterable-s-react-native-sdk)

// Below is a sample implementation of the config object where we set the urlHAndler and inAppDisplayInterval

const config = new IterableConfig();

// inAppDisplayInterval sets the number of seconds to wait between displaying multiple in-app messages in sequence
config.inAppDisplayInterval = 1.0;

// urlHandler is set up here to handle deep link URLs and in-app message buttons and link URLs
config.urlHandler = this.urlHandler;

// Initialize by calling the Iterable.initialize method passing in your API key and the optional config object.
Iterable.initialize(iterableAPIKey, config);
}
render() {
const Tab = createBottomTabNavigator();
return (React.createElement(NavigationContainer, null,
React.createElement(Tab.Navigator, { screenOptions: ({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
if (route.name == 'Home') {
return React.createElement(Icon, { name: "ios-home", size: size, color: color });
}
else {
return React.createElement(Icon, { name: "ios-settings", size: size, color: color });
}
},
}), tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
showIcon: true,
} },
React.createElement(Tab.Screen, { name: "Home", options: { title: "Coffees" } }, props => React.createElement(HomeTab, Object.assign({ ref: this.homeTabRef }, props))),
React.createElement(Tab.Screen, { name: "Settings", component: SettingsTab }))));
}

// Initialize by calling the Iterable.initialize method passing in your API key and the optional config object.
Iterable.initialize(iterableAPIKey, config)
}
navigate(coffee) {
if (this.homeTabRef && this.homeTabRef.current) {
this.homeTabRef.current.navigate(coffee);
}
}

render () {
const Tab = createBottomTabNavigator()
return (React.createElement(NavigationContainer, null,
React.createElement(Tab.Navigator, {
screenOptions: ({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
if (route.name === 'Home') {
return React.createElement(Icon, { name: 'ios-home', size, color })
// urlHandler is defined here
urlHandler = (url, context) => {
console.log(`urlHandler, url: ${url}`);
let match = url.match(/coffee\/([^\/]+)/i);
if (match && match.length > 1) {
const id = match[1];
const foundCoffee = coffees.find(coffee => coffee.id == id);
if (foundCoffee) {
this.navigate(foundCoffee);
} else {
return React.createElement(Icon, { name: 'ios-settings', size, color })
console.log(`could not find coffee with id: ${id}`);
}
}
}),
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
showIcon: true
return true;
} else {
console.log("opening external url");
return false;
}
},
React.createElement(Tab.Screen, { name: 'Home', options: { title: 'Coffees' } }, props => React.createElement(HomeTab, Object.assign({ ref: this.homeTabRef }, props))),
React.createElement(Tab.Screen, { name: 'Settings', component: SettingsTab }))))
}

navigate (coffee) {
if (this.homeTabRef && this.homeTabRef.current) {
this.homeTabRef.current.navigate(coffee)
}
}

// urlHandler is defined here
urlHandler = (url, context) => {
console.log(`urlHandler, url: ${url}`)
const match = url.match(/coffee\/([^]+)/i)
if (match && match.length > 1) {
const id = match[1]
const foundCoffee = coffees.find(coffee => coffee.id === id)
if (foundCoffee) {
this.navigate(foundCoffee)
} else {
console.log(`could not find coffee with id: ${id}`)
}
return true
} else {
console.log('opening external url')
return false
}
}
}
}
14 changes: 7 additions & 7 deletions SampleApp/javascript/js/Data.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export declare interface Coffee {
id: string
name: string
icon: any
subtitle: string
}
export declare const coffees: Coffee[]
export declare type Coffee = {
id: string;
name: string;
icon: any;
subtitle: string;
};
export declare const coffees: Array<Coffee>;
32 changes: 16 additions & 16 deletions SampleApp/javascript/js/Data.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export const coffees = [{
id: 'black',
name: 'Black Coffee',
icon: require('../img/black-coffee.png'),
subtitle: 'It\'s great for weight loss'
}, {
id: 'cappuccino',
name: 'Cappuccino',
icon: require('../img/cappuccino.png'),
subtitle: 'It is tasty'
}, {
id: 'mocha',
name: 'Mocha',
icon: require('../img/mocha.png'),
subtitle: 'Indulge yourself'
}
]
id: "black",
name: 'Black Coffee',
icon: require('../img/black-coffee.png'),
subtitle: 'It\'s great for weight loss'
}, {
id: "cappuccino",
name: 'Cappuccino',
icon: require('../img/cappuccino.png'),
subtitle: 'It is tasty'
}, {
id: 'mocha',
name: 'Mocha',
icon: require('../img/mocha.png'),
subtitle: 'Indulge yourself'
},
];
24 changes: 12 additions & 12 deletions SampleApp/javascript/js/DetailScreen.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component } from 'react'
import { RouteProp } from '@react-navigation/native'
import { StackNavigationProp } from '@react-navigation/stack'
import { Screens } from './HomeTab'
declare interface DetailScreenProps {
route: RouteProp<Screens, 'Detail'>
navigation: StackNavigationProp<Screens>
}
import { Component } from 'react';
import { RouteProp } from '@react-navigation/native';
import { StackNavigationProp } from '@react-navigation/stack';
import { Screens } from './HomeTab';
declare type DetailScreenProps = {
route: RouteProp<Screens, 'Detail'>;
navigation: StackNavigationProp<Screens>;
};
export default class DetailScreen extends Component<DetailScreenProps> {
constructor (props: DetailScreenProps)
render (): JSX.Element
private readonly buyTapped
constructor(props: DetailScreenProps);
render(): JSX.Element;
private buyTapped;
}
export {}
export {};
Loading