-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from engage-so/firebase_notifications
Firebase notifications
- Loading branch information
Showing
20 changed files
with
1,198 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "abseil-cpp-binary", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/abseil-cpp-binary.git", | ||
"state" : { | ||
"revision" : "194a6706acbd25e4ef639bcaddea16e8758a3e27", | ||
"version" : "1.2024011602.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "app-check", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/app-check.git", | ||
"state" : { | ||
"revision" : "3b62f154d00019ae29a71e9738800bb6f18b236d", | ||
"version" : "10.19.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "firebase-ios-sdk", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/firebase/firebase-ios-sdk", | ||
"state" : { | ||
"revision" : "eca84fd638116dd6adb633b5a3f31cc7befcbb7d", | ||
"version" : "10.29.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "googleappmeasurement", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/GoogleAppMeasurement.git", | ||
"state" : { | ||
"revision" : "fe727587518729046fc1465625b9afd80b5ab361", | ||
"version" : "10.28.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "googledatatransport", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/GoogleDataTransport.git", | ||
"state" : { | ||
"revision" : "a637d318ae7ae246b02d7305121275bc75ed5565", | ||
"version" : "9.4.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "googleutilities", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/GoogleUtilities.git", | ||
"state" : { | ||
"revision" : "57a1d307f42df690fdef2637f3e5b776da02aad6", | ||
"version" : "7.13.3" | ||
} | ||
}, | ||
{ | ||
"identity" : "grpc-binary", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/grpc-binary.git", | ||
"state" : { | ||
"revision" : "e9fad491d0673bdda7063a0341fb6b47a30c5359", | ||
"version" : "1.62.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "gtm-session-fetcher", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/gtm-session-fetcher.git", | ||
"state" : { | ||
"revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b", | ||
"version" : "3.5.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "interop-ios-for-google-sdks", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/interop-ios-for-google-sdks.git", | ||
"state" : { | ||
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", | ||
"version" : "100.0.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "leveldb", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/firebase/leveldb.git", | ||
"state" : { | ||
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1", | ||
"version" : "1.22.5" | ||
} | ||
}, | ||
{ | ||
"identity" : "nanopb", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/firebase/nanopb.git", | ||
"state" : { | ||
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1", | ||
"version" : "2.30910.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "promises", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/google/promises.git", | ||
"state" : { | ||
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", | ||
"version" : "2.4.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-protobuf", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-protobuf.git", | ||
"state" : { | ||
"revision" : "edb6ed4919f7756157fe02f2552b7e3850a538e5", | ||
"version" : "1.28.1" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Engage iOS SDK | ||
|
||
[Engage](https://engage.so/) helps businesses deliver personalized customer messaging and marketing automation through email, SMS and in-app messaging. This iOS SDK makes it easy to identify customers, sync customer data (attributes, events and device tokens) to the Engage dashboard and send in-app messages to customers. | ||
|
||
## Features | ||
|
||
- Track device token | ||
- Identify users | ||
- Update user attributes | ||
- Track user events | ||
|
||
## Getting started | ||
|
||
- [Create an Engage account](https://engage.so/) and set up an account to get your public API key. | ||
- Learn about [connecting customer data](https://engage.so/docs/guides/connecting-user-data) to Engage. | ||
|
||
## Installation | ||
|
||
The SDK is available via SPM or Cocoapods. | ||
|
||
### Swift Package Manager (SPM) | ||
|
||
1. In Xcode, go to your project’s **Package Dependencies** section. | ||
2. Click the **+** button to add a new package. | ||
3. Enter the following URL: | ||
|
||
``` | ||
https://github.com/engage-so/engage-ios.git | ||
``` | ||
|
||
4. Choose the version you want to install, and add it to your project. | ||
|
||
### CocoaPods | ||
|
||
1. Add the Engage SDK to your `Podfile`: | ||
|
||
```ruby | ||
platform :ios, '13.0' | ||
|
||
target 'YourAppTarget' do | ||
use_frameworks! | ||
|
||
pod 'Engage-swift', :git => 'https://github.com/engage-so/engage-ios.git', :tag => 'v1.0.0' | ||
end | ||
``` | ||
|
||
2. Install the dependencies by running: | ||
|
||
```bash | ||
pod install | ||
``` | ||
|
||
#### Example of Dependency Declaration in `Package.swift` | ||
|
||
If you are using Swift Package Manager programmatically in a `Package.swift` file: | ||
|
||
```swift | ||
dependencies: [ | ||
.package(url: "https://github.com/engage-so/engage-ios.git", from: "1.0.0") | ||
] | ||
``` | ||
|
||
## Initialization | ||
|
||
Import `Engage` and initialize the SDK. | ||
|
||
```swift | ||
// ... | ||
import Engage | ||
|
||
@main | ||
struct MainApp: App { | ||
init() { | ||
Engage.shared.initialise(publicKey: "public-api-key") | ||
} | ||
// ... | ||
} | ||
``` | ||
|
||
## Identify users | ||
|
||
Engage uses your user's unique identifier (this is mostly the ID field of the users' table) for data tracking. **Identify** lets you link this ID to the user. With identify, you are able to supply more details about the user. | ||
|
||
```swift | ||
let properties = ["first_name": "Jane", "last_name": "Doe", "last_login": Date()] | ||
Engage.shared.identify(uid: "user-id", properties: properties) | ||
``` | ||
|
||
Engage supports the following standard attributes: `first_name`, `last_name`, `email`, `number` (customer's phone number) but you can use identify to add any customer attribute you want. `last_login` in the example above is an example. | ||
|
||
When new users are identified, Engage assumes their signup date to be the current timestamp. You can change this by adding a `created_at` attribute. | ||
|
||
```swift | ||
let properties = ["first_name": "Jane", "last_name": "Doe", "created_at": "2021-01-04"] | ||
Engage.shared.identify(uid: "user-id", properties: properties) | ||
``` | ||
|
||
## Add attributes | ||
|
||
To add more attributes to the user's profile, use the `addAttributes` method. | ||
|
||
```swift | ||
let attributes = ["plan": "Pro", "age": 14] | ||
Engage.shared.addAttributes(properties: attributes, uid: "optional") | ||
``` | ||
|
||
## Set device token | ||
|
||
Engage integrates with [FCM](https://firebase.google.com/docs/cloud-messaging) to let you send push notifications to your users, either through broadcast or automation. However, to do this, you need to send the user's FCM registration token to Engage. The device registration token is a unique identifier that allows the device receive messages. | ||
|
||
```swift | ||
func onNewToken(token: String) { | ||
Engage.shared.setDeviceToken(deviceToken: token, uid: "optional") | ||
} | ||
``` | ||
|
||
## Track events | ||
|
||
Track an event: | ||
|
||
```swift | ||
Engage.shared.track(event: "Login", uid: "optional") | ||
``` | ||
|
||
Track an event with a value: | ||
|
||
```swift | ||
Engage.shared.track(event: "Clicked", value: "Login button", uid: "optional") | ||
``` | ||
|
||
Track an event with properties: | ||
|
||
```swift | ||
let properties = ["type": "button", "counter": counter] | ||
Engage.shared.track(event: "Clicked", value: properties, uid: "optional") | ||
``` | ||
|
||
Engage sets the event date to the current timestamp but if you would like to set a different date, you can add a date as an argument in the `track` method. | ||
|
||
```swift | ||
Engage.shared.track(event: "Clicked", value: "Login button", date: Date(), uid: "optional") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.