Purchasely
4.4
4.4
  • Welcome page
  • General
    • Presentation
    • Release notes
  • Quick start
    • Console Configuration
    • SDK Implementation
    • Testing
    • Sample
  • Basic configuration
    • Console Configuration
      • Creating a new application
      • Creating your Products
        • App Store
        • Play Store
        • Huawei App Gallery
        • Amazon App Store
        • Products & Plans
      • Design your Paywalls
      • Design your Paywalls-Latest
        • Carousel
        • Carousel Flow
        • Features List
        • Features List & Plan Picker with 2 & 3 columns
        • Feature list overlay
        • Plan picker horizontal
        • Plan picker with 2 and 3 Column
    • SDK installation
      • iOS SDK
      • Android SDK
      • React Native SDK
      • Cordova SDK
      • Flutter SDK
      • Unity SDK
    • SDK configurations
      • Paywall observer mode
      • Full mode
      • StoreKit 2
      • Appendices
        • Start the SDK
        • Set User Id
        • Notify when the app is ready
        • Present paywalls
        • Unlock content / service
        • Close SDK (Android only)
    • Stripe
    • Purchasely with RevenueCat
  • S2S notifications
    • Server-to-server notifications ?
    • Apple App Store
    • Google Play Store
    • Huawei App Gallery
  • Analytics
    • Dashboards
      • Introduction
      • Live
      • Subscriptions
      • Cohorts
      • Trials
      • Events
    • Events
      • Webhook events
        • Subscription events
        • Subscription events attributes
      • SDK events
        • UI events
        • UI attributes
  • Integrations
    • Webhook
      • Receiving and understanding messages
      • Managing entitlements
      • Detailed sequence diagrams
    • Airship
    • Amplitude
    • AppsFlyer
    • Adjust
    • Piano analytics(ex AT Internet)
    • Batch
    • Branch
    • Braze
    • Clevertap
    • Customer.io
    • Firebase
    • Iterable
    • Mixpanel
    • MoEngage
    • OneSignal
    • Segment
    • Brevo(ex Sendinblue)
  • Advanced Features
    • Asynchronous paywalls
    • NEW: Promotional offers
    • Anonymous user
    • Associating content
    • Audiences
    • Customising UI
      • Errors & alerts
      • Controllers (iOS) / Fragments (Android)
    • Deeplinks automations
    • Disable placements
    • Displaying users subscriptions
    • Localization
    • Lottie animations
    • Non-subscription products
    • Paywall action interceptor
    • Promoting your products
      • Self-promotion
      • Promoting In-App Purchases
    • Purchase manually
    • Subscription status
    • Use your own paywall
  • Others
    • Frequently Asked Questions
    • Migration guides
      • Migrate to Purchasely
      • Webhook
        • Migrate to Webhook v3.0
      • SDK
        • Migrate to SDK v3.0
          • v2.2.0
          • v2.1.3
        • Migrate to SDK v3.1
        • Migrate to SDK v3.2
        • Migrate to SDK v4.0.0
  • TESTING
    • Testing Cycle Durations
Powered by GitBook

© Purchasely 2020-2023

On this page
  • Events
  • Associate your users
  • From within your app
  • From your server
  • Handle anonymous users
  • Configure the integration in the Purchasely Console
  • Event example
  • Create your automation!

Was this helpful?

Edit on GitHub
  1. Integrations

Airship

PreviousDetailed sequence diagramsNextAmplitude

Last updated 1 year ago

Was this helpful?

Events

The following events will be sent. You can set the event name of your choice in the console.

You can find the full list of events .

Event
Description

SUBSCRIPTION_STARTED

Sent when the user purchased a product wether it is the start of a trial or a regular purchase of a consumable product.

RENEWAL_DISABLED

Sent when the user deactivates the renewal of a subscription wether it is in trial period or not.

RENEWAL_ENABLED

Sent when the user reactivates

SUBSCRIPTION_TERMINATED

Sent when the subscription actually ends

SUBSCRIPTION_RENEWED

Sent when a subscription renews

TRIAL_STARTED

Sent when a trial starts

TRIAL_CONVERTED

Sent when a user converts from a free trial to a normal paid-period

TRIAL_NOT_CONVERTED

Sent when a user finishes it's trial period without renewing to a paid-period

Associate your users

Naming your users allows our servers to send purchase events on your behalf to Airship. You have 2 ways of doing it:

From within your app

In your app, when a user sign-in, associate their id in Airship.

If the Airship UserId differs from the Purchasely UserId, you can also pass the value you gave to Airship to Purchasely SDK (see second code block):

UAirship.namedUser().identifier = "theUserId"
Purchasely.setAttribute(.airshipUserId, value: "theUserId")
UAirship.shared().namedUser.id = "YOUR_USER_ID"
Purchasely.setAttribute(
    Attribute.AIRSHIP_USER_ID,
    "YOUR_USER_ID"
)
UAirship.shared().getNamedUser().setId("YOUR_USER_ID");
Purchasely.setAttribute(
    Attribute.AIRSHIP_USER_ID,
    "YOUR_USER_ID"
);
UAirship.setNamedUser("YOUR_USER_ID")
Purchasely.setAttribute(Attributes.AIRSHIP_USER_ID, "YOUR_USER_ID");
UAirship.setNamedUser("YOUR_USER_ID")
Purchasely.setAttribute(AIRSHIP_USER_ID, value: "YOUR_USER_ID");

From your server

By restricting association to server-side calls only, you have the added security of requiring your master secret to be verified after each call. While increasing security, you also lose the convenience of having your application automatically associate named users on login. Most apps do not require this additional security. But, if your app deals with extremely sensitive data, you may want to leave this setting disabled and associate named users exclusively through the API.

require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

named_user = UA::NamedUser.new(client: airship)
named_user.named_user_id = 'user-id-1234'
named_user.associate(
    channel_id: 'df6a6b50-9843-0304-d5a5-743f246a4946',
    device_type: 'ios'
  )
import urbanairship as ua

airship = ua.Airship('<app key>', '<master secret>')
named_user = ua.NamedUser(airship, 'user-id-1234')
resp = named_user.associate('df6a6b50-9843-0304-d5a5-743f246a4946', 'ios')
UrbanAirshipClient client = UrbanAirshipClient.newBuilder()
        .setKey("<app key>")
        .setSecret("<master secret>")
        .build();

NamedUserRequest request = NamedUserRequest.newAssociationRequest()
        .setChannel("df6a6b50-9843-0304-d5a5-743f246a4946", ChannelType.IOS)
        .setNamedUserId("user-id-1234");

Response<String> response = client.execute(request);

Handle anonymous users

if let channelId = UAirship.channel()?.identifier {
	Purchasely.setAttribute(.airshipChannelId, value: channelId)
}
if ([[UAirship channel] identifier] != nil) {
		[Purchasely setAttribute:PLYAttributeAirshipChannelId value: [[UAirship channel] identifier]];
	}
UAirship.shared().channel.id?.let {
    Purchasely.setAttribute(
        Attribute.AIRSHIP_CHANNEL_ID,
        it
    )
}
String channelId = UAirship.shared().getChannel().getId();
if(UAirship.shared().getChannel().getId() != null) {
    Purchasely.setAttribute(
            Attribute.AIRSHIP_CHANNEL_ID,
            channelId
    );
}
var channelId = UrbanAirship.getChannelId().then(channelId => {
  Purchasely.setAttribute(Attributes.AIRSHIP_CHANNEL_ID, channelId);
}));
UAirship.getChannelID(function (channelID) {
    Purchasely.setAttribute(AIRSHIP_CHANNEL_ID, value: channelId);
})

Configure the integration in the Purchasely Console

Go in the "External integrations" section, and open the edition form for Airship:

You'll find your "Airship API key" in your Airship console, section "Settings » APIs & Integrations":

You need to generate the "Airship API token" in your Airship console, section "Settings » APIs & Integrations » Tokens", with the "Audience Modification" role:

Finally, the "Server" to use depends on your app.

  • If your Airship console is on the "go.airship.com" domain, then you'll need to choose the "go.urbanairship.com" server.

  • If your Airship console is on the "go.airship.eu" domain, then you'll need to choose the "go.airship.eu" server.

If you want to, you can rename the events sent to Airship:

And also choose to update user properties:

Event example

{
  "body": {
    "name": "purchase_validated_server",
    "properties": {
      "application_name": "Purchasely",
      "application_package_id": "com.purchasely",
      "application_platform": "IOS",
      "plan_id": "PURCHASELY_PLUS_MONTHLY",
      "plan_name": "Monthly",
      "plan_store_product_id": "com.purchasely.plus.monthly",
      "plan_type": "RENEWING_SUBSCRIPTION",
      "product_id": "PURCHASELY_PLUS",
      "product_name": "Purchasely +",
      "store": "APPLE_APP_STORE"
    }
  },
  "occurred":"2021-03-24T17:15:01",
  "user":{
    "named_user_id": "jg"
  }
}

Create your automation!

And that's all!

From now on, you'll be able to create as many automations as you want based on Purchasely's events with Airship!

In the Airship console, enable or disable Named Usersin "Settings" APIs & Integrations » Named Users".

More information on "named users" can be found

Use the Airship API to associate your users

If you have in your app, we'll need the Airship channel to send purchase events to Airship on your behalf.

The overridden name must only contain alphanumeric lowercase characters, underscores and dashes, as .

here
From within the app
From your server
here
here
anonymous users
specified in the Airship documentation