|
| 1 | +#### `npm install` |
| 2 | +#### `npm run ios` |
| 3 | + |
| 4 | +You must integrate the documentaion Talkable IOS SDK http://docs.talkable.com/ios_sdk/getting_started.html# |
| 5 | + |
| 6 | +After you create Native Module IOS for calling the methods of Talkable IOS SDK from React Native Application: |
| 7 | + |
| 8 | +1. Create your module files |
| 9 | + Open the workspace for your app in Xcode and create a new file. Select Cocoa Touch Class to create both a header and an implementation file. |
| 10 | + Make sure it subclasses NSObject and save it in your App folder. |
| 11 | +2. Update your header file |
| 12 | + A .h header file contains all the information about a class that should be publicly known like properties and functions. |
| 13 | + Update your header file to implement React’s RCTBridgeModule: |
| 14 | + |
| 15 | + TalkableBridge.h ( ios/TalkableBridge/TalkableBridge.h) |
| 16 | + |
| 17 | +3. Update your implementation file |
| 18 | + A .m implementation file contains the implementations of all functions listed in the header and any private instance variables and methods. |
| 19 | + |
| 20 | + Your class should contain two macros, RCT_EXPORT_MODULE() and RCT_EXPORT_METHOD() . Update your .m file to implement these two macros. |
| 21 | + |
| 22 | + RCT_EXPORT_MODULE registers our module with the bridge. It takes an optional argument in case you want to name the JavaScript (JS) module differently to the Objective-C class name. |
| 23 | + |
| 24 | + RCT_EXPORT_METHOD macro exposes our new method to JS. In this case, we’re just logging the supplied argument back to the console. |
| 25 | + |
| 26 | + You must call all native method of Talkable SDK IOS in the main thread. |
| 27 | + |
| 28 | + dispatch_async(dispatch_get_main_queue(), ^{ |
| 29 | + [[Talkable manager] registerOrigin:TKBLAffiliateMember params:nil]; |
| 30 | + }); |
| 31 | + |
| 32 | + TalkableBridge.m (ios/TalkableBridge/TalkableBridge.m) |
| 33 | + |
| 34 | +4. Use your Talkable Native Method in JS |
| 35 | + Our new method is now available in JS through the NativeModules object: |
| 36 | + - method showStandaloneCampaign in App.js for Standalone Campaign (http://docs.talkable.com/ios_sdk/integration/standalone.html#ios-sdk-integration-standalone) |
| 37 | + - method showPostPurchaseCampaign in App.js for Post Purchase Campaign (http://docs.talkable.com/ios_sdk/integration/post_purchase.html#ios-sdk-integration-post-purchase) |
| 38 | + |
1 | 39 | This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app).
|
2 | 40 |
|
3 | 41 | Below you'll find information about performing common tasks. The most recent version of this guide is available [here](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md).
|
@@ -81,121 +119,12 @@ This will start the process of "ejecting" from Create React Native App's build s
|
81 | 119 |
|
82 | 120 | **Warning:** Running eject is a permanent action (aside from whatever version control system you use). An ejected app will require you to have an [Xcode and/or Android Studio environment](https://facebook.github.io/react-native/docs/getting-started.html) set up.
|
83 | 121 |
|
84 |
| -## Customizing App Display Name and Icon |
85 |
| - |
86 |
| -You can edit `app.json` to include [configuration keys](https://docs.expo.io/versions/latest/guides/configuration.html) under the `expo` key. |
87 |
| - |
88 |
| -To change your app's display name, set the `expo.name` key in `app.json` to an appropriate string. |
89 |
| - |
90 |
| -To set an app icon, set the `expo.icon` key in `app.json` to be either a local path or a URL. It's recommended that you use a 512x512 png file with transparency. |
91 |
| - |
92 |
| -## Writing and Running Tests |
93 |
| - |
94 |
| -This project is set up to use [jest](https://facebook.github.io/jest/) for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called `__tests__` or with the `.test` extension to have the files loaded by jest. See the [the template project](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/App.test.js) for an example test. The [jest documentation](https://facebook.github.io/jest/docs/en/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/en/tutorial-react-native.html). |
95 |
| - |
96 |
| -## Environment Variables |
97 |
| - |
98 |
| -You can configure some of Create React Native App's behavior using environment variables. |
99 |
| - |
100 |
| -### Configuring Packager IP Address |
101 |
| - |
102 |
| -When starting your project, you'll see something like this for your project URL: |
103 |
| - |
104 |
| -``` |
105 |
| -exp://192.168.0.2:19000 |
106 |
| -``` |
107 |
| - |
108 |
| -The "manifest" at that URL tells the Expo app how to retrieve and load your app's JavaScript bundle, so even if you load it in the app via a URL like `exp://localhost:19000`, the Expo client app will still try to retrieve your app at the IP address that the start script provides. |
109 |
| - |
110 |
| -In some cases, this is less than ideal. This might be the case if you need to run your project inside of a virtual machine and you have to access the packager via a different IP address than the one which prints by default. In order to override the IP address or hostname that is detected by Create React Native App, you can specify your own hostname via the `REACT_NATIVE_PACKAGER_HOSTNAME` environment variable: |
111 |
| - |
112 |
| -Mac and Linux: |
113 |
| - |
114 |
| -``` |
115 |
| -REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start |
116 |
| -``` |
117 |
| - |
118 |
| -Windows: |
119 |
| -``` |
120 |
| -set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' |
121 |
| -npm start |
122 |
| -``` |
123 |
| - |
124 |
| -The above example would cause the development server to listen on `exp://my-custom-ip-address-or-hostname:19000`. |
125 |
| - |
126 | 122 | ## Sharing and Deployment
|
127 | 123 |
|
128 | 124 | Create React Native App does a lot of work to make app setup and development simple and straightforward, but it's very difficult to do the same for deploying to Apple's App Store or Google's Play Store without relying on a hosted service.
|
129 | 125 |
|
130 |
| -### Publishing to Expo's React Native Community |
131 |
| - |
132 |
| -Expo provides free hosting for the JS-only apps created by CRNA, allowing you to share your app through the Expo client app. This requires registration for an Expo account. |
133 |
| - |
134 |
| -Install the `exp` command-line tool, and run the publish command: |
135 |
| - |
136 |
| -``` |
137 |
| -$ npm i -g exp |
138 |
| -$ exp publish |
139 |
| -``` |
140 |
| - |
141 |
| -### Building an Expo "standalone" app |
142 |
| - |
143 |
| -You can also use a service like [Expo's standalone builds](https://docs.expo.io/versions/latest/guides/building-standalone-apps.html) if you want to get an IPA/APK for distribution without having to build the native code yourself. |
144 |
| - |
145 | 126 | ### Ejecting from Create React Native App
|
146 | 127 |
|
147 | 128 | If you want to build and deploy your app yourself, you'll need to eject from CRNA and use Xcode and Android Studio.
|
148 | 129 |
|
149 | 130 | This is usually as simple as running `npm run eject` in your project, which will walk you through the process. Make sure to install `react-native-cli` and follow the [native code getting started guide for React Native](https://facebook.github.io/react-native/docs/getting-started.html).
|
150 |
| - |
151 |
| -#### Should I Use ExpoKit? |
152 |
| - |
153 |
| -If you have made use of Expo APIs while working on your project, then those API calls will stop working if you eject to a regular React Native project. If you want to continue using those APIs, you can eject to "React Native + ExpoKit" which will still allow you to build your own native code and continue using the Expo APIs. See the [ejecting guide](https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md) for more details about this option. |
154 |
| - |
155 |
| -## Troubleshooting |
156 |
| - |
157 |
| -### Networking |
158 |
| - |
159 |
| -If you're unable to load your app on your phone due to a network timeout or a refused connection, a good first step is to verify that your phone and computer are on the same network and that they can reach each other. Create React Native App needs access to ports 19000 and 19001 so ensure that your network and firewall settings allow access from your device to your computer on both of these ports. |
160 |
| - |
161 |
| -Try opening a web browser on your phone and opening the URL that the packager script prints, replacing `exp://` with `http://`. So, for example, if underneath the QR code in your terminal you see: |
162 |
| - |
163 |
| -``` |
164 |
| -exp://192.168.0.1:19000 |
165 |
| -``` |
166 |
| - |
167 |
| -Try opening Safari or Chrome on your phone and loading |
168 |
| - |
169 |
| -``` |
170 |
| -http://192.168.0.1:19000 |
171 |
| -``` |
172 |
| - |
173 |
| -and |
174 |
| - |
175 |
| -``` |
176 |
| -http://192.168.0.1:19001 |
177 |
| -``` |
178 |
| - |
179 |
| -If this works, but you're still unable to load your app by scanning the QR code, please open an issue on the [Create React Native App repository](https://github.com/react-community/create-react-native-app) with details about these steps and any other error messages you may have received. |
180 |
| - |
181 |
| -If you're not able to load the `http` URL in your phone's web browser, try using the tethering/mobile hotspot feature on your phone (beware of data usage, though), connecting your computer to that WiFi network, and restarting the packager. If you are using a VPN you may need to disable it. |
182 |
| - |
183 |
| -### iOS Simulator won't open |
184 |
| - |
185 |
| -If you're on a Mac, there are a few errors that users sometimes see when attempting to `npm run ios`: |
186 |
| - |
187 |
| -* "non-zero exit code: 107" |
188 |
| -* "You may need to install Xcode" but it is already installed |
189 |
| -* and others |
190 |
| - |
191 |
| -There are a few steps you may want to take to troubleshoot these kinds of errors: |
192 |
| - |
193 |
| -1. Make sure Xcode is installed and open it to accept the license agreement if it prompts you. You can install it from the Mac App Store. |
194 |
| -2. Open Xcode's Preferences, the Locations tab, and make sure that the `Command Line Tools` menu option is set to something. Sometimes when the CLI tools are first installed by Homebrew this option is left blank, which can prevent Apple utilities from finding the simulator. Make sure to re-run `npm/yarn run ios` after doing so. |
195 |
| -3. If that doesn't work, open the Simulator, and under the app menu select `Reset Contents and Settings...`. After that has finished, quit the Simulator, and re-run `npm/yarn run ios`. |
196 |
| - |
197 |
| -### QR Code does not scan |
198 |
| - |
199 |
| -If you're not able to scan the QR code, make sure your phone's camera is focusing correctly, and also make sure that the contrast on the two colors in your terminal is high enough. For example, WebStorm's default themes may [not have enough contrast](https://github.com/react-community/create-react-native-app/issues/49) for terminal QR codes to be scannable with the system barcode scanners that the Expo app uses. |
200 |
| - |
201 |
| -If this causes problems for you, you may want to try changing your terminal's color theme to have more contrast, or running Create React Native App from a different terminal. You can also manually enter the URL printed by the packager script in the Expo app's search bar to load it manually. |
0 commit comments