|
| 1 | +<img src="https://raw.githubusercontent.com/EddyVerbruggen/nativescript-plugin-firebase/master/docs/images/features/invites.png" height="85px" alt="Invites"/> |
| 2 | + |
| 3 | +## Enabling Invites |
| 4 | +Since plugin version 3.12.0 you can use Firebase _Invites_ features. |
| 5 | + |
| 6 | +_Invites_ lets you invite other users to your app from right within your own app, via SMS and/or Email. |
| 7 | + |
| 8 | +### iOS |
| 9 | +* On iOS the user must be signed in with their Google Account to send invitations. |
| 10 | +* You must have the App Store ID set in your developer console project in order for invitations to successfully be sent. |
| 11 | +* For more details see [https://firebase.google.com/docs/invites/ios](https://firebase.google.com/docs/invites/ios). |
| 12 | + |
| 13 | +#### Contacts Usage Permission |
| 14 | +Open `app/App_Resources/iOS/Info.plist` and add this somewhere in the file (if it's not already there): |
| 15 | + |
| 16 | +```xml |
| 17 | + <key>NSContactsUsageDescription</key> |
| 18 | + <string>For inviting others to use this app.</string> |
| 19 | +``` |
| 20 | + |
| 21 | +## Functions |
| 22 | + |
| 23 | +### invites.sendInvitation |
| 24 | + |
| 25 | +```js |
| 26 | +firebase.invites.sendInvitation({ |
| 27 | + title: "Invite title here", |
| 28 | + message: "Invite message here" |
| 29 | +}).then( |
| 30 | + function (result) { // SendInvitationResult |
| 31 | + console.log(result.count + "invitations sent, ID's: " + JSON.stringify(result.invitationIds)); |
| 32 | + }, |
| 33 | + function (error) { |
| 34 | + console.log("sendInvitation error: " + error); |
| 35 | + } |
| 36 | +); |
| 37 | +``` |
| 38 | + |
| 39 | +The options you can pass to `sendInvitation` are: |
| 40 | + |
| 41 | +|param|optional|description |
| 42 | +|---|---|--- |
| 43 | +|`title`|no|Invitation title you want to send. |
| 44 | +|`message`|no|Sets the default message sent with invitations. |
| 45 | +|`deepLink`|yes|Sets the link into your app that is sent with invitations. |
| 46 | +|`callToActionText`|yes|Sets the call-to-action text of the button rendered in email invitations. Cannot exceed 32 characters. |
| 47 | +|`customImage`|yes|Sets the URL of a custom image to include in email invitations. The image must be square and around 600x600 pixels. The image can be no larger than 4000x4000 pixels. |
| 48 | +|`androidClientID`|yes|If you have an Android version of your app and you want to send an invitation that can be opened on Android in addition to iOS. |
| 49 | +|`iosClientID`|yes|You can find your iOS app's client ID in the GoogleService-Info.plist file you downloaded from the Firebase console. |
| 50 | + |
| 51 | + |
| 52 | +### invites.getInvitation |
| 53 | +When the user opens your app from an invite, you can retrieve the details via the `getInvitation` function: |
| 54 | + |
| 55 | +```js |
| 56 | +firebase.invites.getInvitation().then( |
| 57 | + function (result) { // GetInvitationResult |
| 58 | + console.log("deeplink: " + result.deeplink + ", invitationId: " result.invitationId); |
| 59 | + }, |
| 60 | + function (error) { |
| 61 | + console.log("getInvitation error: " + error); |
| 62 | + } |
| 63 | +); |
| 64 | +``` |
0 commit comments