You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Run it on iOS / Android](#3-run-it-on-ios--android)
46
23
-[Credits](#credits)
47
24
48
25
## Installation
49
26
50
-
### 1. Install Javascript packages
27
+
### 1. Integrate the base Facebook SDK
51
28
52
-
##### RN >= 0.40
29
+
Follow the instructions on [react-native-fbsdk](https://github.com/facebook/react-native-fbsdk) to integrate the Facebook SDK into your project.
30
+
Note that for iOS, it's [recommended you use Cocoapods](https://developers.facebook.com/docs/ios/getting-started/advanced) rather than the manual installation.
If you didn't use Cocoapods to integrate the Facebook SDK, you'll need to manually add the audience network framework file to your project.
76
43
77
-
//IOS NOTICE
78
-
Use pod to install fbAudience framework
79
-
```
44
+
### 3. Install The Javascript Package
80
45
81
-
### 2. Configure native projects
46
+
Add the package to your project using your favorite package manager
82
47
83
-
The react-native-fbads has been automatically linked for you, the next step will be downloading and linking the native Facebook SDK for both platforms.
48
+
```bash
49
+
$ yarn install react-native-fbads
50
+
```
84
51
85
-
#### 2.1 iOS
52
+
Link the native dependencies
86
53
87
-
Make sure you have the latest Xcode installed. Open the .xcodeproj in Xcode found in the ios subfolder from your project's root directory. Now, follow all the steps in the [Getting Started Guide for Facebook SDK](https://developers.facebook.com/docs/ios/getting-started) for iOS. Along with FBSDKCoreKit.framework, don't forget to import FBAudienceNetwork.framework.
54
+
```bash
55
+
$ react-native link react-native-fbads
56
+
```
88
57
89
-
Next, **follow steps 1 and 3** from the [Getting Started Guide for Facebook Audience](https://developers.facebook.com/docs/audience-network/getting-started). Once you have created the `placement id`, write it down and continue to next section.
58
+
### 4. Get a Placement ID
90
59
91
-
#### 2.2. Android
60
+
Follow [Facebook's instructions](https://www.facebook.com/help/publisher/1195459597167215) to create placement IDs for your ads.
92
61
93
-
If you are using [`react-native-fbsdk`](https://github.com/facebook/react-native-fbsdk) you can follow their installation instructions. Otherwise, please follow official [Getting Started Guide for Facebook SDK](https://developers.facebook.com/docs/android/getting-started).
62
+
You can skip the _Integrate the SDK_ step of that guide, as you've already integrated the Facebook SDK in previous steps.
94
63
95
64
## Usage
96
65
97
-
For detailed usage please check `examples` folder.
98
-
99
66
### Interstitial Ads
100
67
101
-
Interstitial Ad is a type of an ad that displays full screen with media content. It has a dismiss button as well as the clickable area that takes user outside of your app.
68
+
An Interstitial Ad is a an ad that covers the whole screen with media content. It has a dismiss button as well as the clickable area that takes user outside of your app.
They are displayed over your root view with a single, imperative call.
72
+
Interstitial ads are displayed over your root view with a single, imperative call.
106
73
107
-
#### 1. Showing ad
74
+
On android, you'll need to add the following to your `AndroidManifest.xml`:
108
75
109
-
In order to show an ad, you have to import `InterstitialAdManager` and call `showAd` on it supplying it a placementId identifier, as in the below example:
Method returns a promise that will be rejected when an error occurs during a call (e.g. no fill from ad server or network error) and resolve when user either dimisses or interacts with the displayed ad.
92
+
The `showAd` method returns a promise that will be resolves once the ad has been either dismissed or clicked by the user. The promise will reject if an erros occurs before displaying the ad, such as a network error.
120
93
121
94
### Native Ads
122
95
123
-
Native Ad is a type of an ad that matches the form and function of your React Native interface.
96
+
Native Ads allow you to create custom ad layouts that match your app. Before proceeding, please review [Facebook's documentation on Native Ads](https://developers.facebook.com/docs/audience-network/native-ads/) to get a better understanding of the requirements Native Ads impose.
RewardedVideoAdManager is a manager that allows you to load a rewarded video, then show the video once the video is loaded, in that order.
334
-
335
-
#### loadAd
336
-
337
-
Loads a rewarded video asynchronously, returns success / true if it loads, error if there wasn't an ad fill or an error from the audience network SDK.
338
-
339
-
```js
340
-
RewardedVideoAdManager.loadAd('placementId')
341
-
.then(...) // fill success
342
-
.catch(...); // no fill or SDK error
343
-
```
344
-
345
-
#### showAd
346
-
347
-
Shows a rewarded video immediately, returns success if the video was watched to completion and the user should be rewarded, error if the video wasn't complete or there was an error from the audience network SDK.
348
-
349
-
```js
350
-
RewardedVideoAdManager.showAd()
351
-
.then(...) // fully watched video, set your reward.
352
-
.catch(...); // error
353
-
```
354
-
355
-
**Note:** You need to be sure to load then show each time you wish to show a rewarded video ad. You also cannot load another video in the success callback of showAd().
356
-
357
254
### AdSettings
358
255
359
256
```js
@@ -368,12 +265,10 @@ Constant which contains current device's hash id.
368
265
369
266
#### addTestDevice
370
267
371
-
Registers given device to receive test ads. When you run app on simulator, it should automatically get added. Use it
372
-
to receive test ads in development mode on a standalone phone. Hash of the current device can be obtained from a
373
-
debug log or `AdSettings.currentDeviceHash` constant.
374
-
375
-
All devices should be specified before any other action takes place, like [`AdsManager`](#nativeadsmanager) gets created.
268
+
Registers given device to receive test ads. When running on a real device, call this method with the result of `AdSettings.currentDeviceHash` to get test ads.
269
+
Do not call this method in production.
376
270
271
+
You should register test devices before displaying any ads or creating any ad managers.
**Note:** This method should never be used in production
427
322
428
-
## Running example
323
+
## Running the example
429
324
430
325
In order to see ads you will have to create your own `placementId` and use it instead of the one provided in the examples. This is our internal set up that doesn't work for any developers outside of Callstack.io organisation. This is because of Facebook not showing test ads to outside collaborators in the development mode.
0 commit comments