Integration with Insider platform products. Bridge plugin with native Insider SDK's.
npm install insider-ionic-plugin
npx cap sync
Insider SDK has some native requirements to run, so please follow the Dependencies and setup modules from native SDK's.
- Setup the project following the instructions in the Insider's Academy
- Add the following dependencies in
android/app/build.gradle
file
dependencies {
// ... all your projects other dependencies
implementation 'com.useinsider:insider:14.2.4-nh'
implementation 'com.useinsider:insiderhybrid:1.1.5'
}
- Setup the project following the instructions in the Insider's Academy
For this sdk push notification's config, click here
await initialize({partnerId: "insider", appGroup: "group.com.insider.capacitor.demotest"});
Usage example:
// User object attributes
await setName({ name: `insider` });
await setSurname({ surname: `capacitor-sdk` });
await setAge({ age: 25 });
await setGender({ gender: "female" });
await setBirthday({ birthday: "1996-06-25" }); //Data should be set in (YYYY-MM-DD) format.
await setFacebookID({ facebookId: "facebookId" });
await setTwitterID({ twitterId: "twitterId" });
await setLanguage({ language: "pt" });
await setLocale({ locale: "pt_BR" });
// Optins
await setEmailOptin({ emailOptIn: true });
await setSMSOptin({ smsOptin: true });
await setLocationOptin({ locationOptin: true });
await setPushOptin({ pushOptIn: true });
// Custom User Attributes
await setCustomAttributeWithBoolean({
key: "boolean_parameter",
value: false,
});
await setCustomAttributeWithDouble({
key: "double_parameter",
value: 20.5,
});
await setCustomAttributeWithInt({
key: "int_parameter",
value: 25,
});
await setCustomAttributeWithString({
key: "string_parameter",
value: "caaqui",
});
await setCustomAttributeWithArray({
key: "array_parameter",
value: ["capacitor", "insider", "ionic"],
});
await setCustomAttributeWithDate({
key: "date_parameter",
value: new Date().toISOString(),
});
// Identifiers
await setPhoneAsIdentifier({ phone: "+5511941231111" });
await setEmailIdentifier({ email: `mobile@insider.com` });
await setUserIdAsIdentifier({ uuid: id });
await login(); // Always call LOGIN after set all the identifiers needed.
await logout();
const product = new InsiderProduct(
"productId",
"name",
["category1"],
"http://www.insider.com",
100.0,
"BRL"
);
product
.setColor("red")
.setGroupcode("groupcode")
.setQuantity(1)
.setStock(10)
.setPromotionDiscount(0.1)
.setPromotionName("promotionName")
.setShippingCost(10.0)
.setSize("size")
.setVoucherDiscount(0.2)
.setSalePrice(90.0);
.addParameterWithArray("array_parameter", [
"insider",
"ionic",
"capacitor",
])
//custom product parameters
.addParameterWithBoolean("boolean_parameter", false)
.addParameterWithDate("date_parameter", new Date().toISOString())
.addParameterWithDouble("double_parameter", 20.5)
.addParameterWithInt("int_parameter", 25)
.addParameterWithString("string_parameter", "caaqui")
await itemAddedToCart({ product: product });
await itemRemovedFromCart({ productId: "productId" });
await itemPurchased({ product: product, saleId: "saleId" });
await cartCleared();
// Events
var event = new InsiderEvent("my_custom_event")
.addParameterWithBoolean("boolean_parameter", false)
.addParameterWithDouble("double_parameter", 20.5)
.addParameterWithInt("int_parameter", 25)
.addParameterWithString("string_parameter", "insider")
.addParameterWithArray("array_parameter", [
"insider",
"ionic",
"capacitor",
])
.addParameterWithDate("date_parameter", new Date().toISOString());
await build({
event: event,
});//Always call build to send event data. If you dont call build, event will not be sent.
// Page View Events
await visitHomePage();
await visitListingPage({taxonomy: ["category1", "category2","category3"]});
await visitProductDetailPage({ product: product });
await visitCartPage({ products: [product, product2] });
initialize(...)
setPhoneAsIdentifier(...)
setEmailIdentifier(...)
setUserIdAsIdentifier(...)
visitHomePage()
visitListingPage(...)
visitCartPage(...)
visitProductDetailPage(...)
setGDPRConsent(...)
setActiveForegroundPushView()
receivedNotification(...)
addListener(EventTypes.CALLBACK_NOTIFICATION_OPEN, ...)
addListener(EventTypes.CALLBACK_INAPP_BUTTON_CLICK, ...)
addListener(EventTypes.CALLBACK_TEMP_STORE_PURCHASE, ...)
addListener(EventTypes.CALLBACK_TEMP_STORE_ADDED_TO_CART, ...)
addListener(EventTypes.CALLBACK_TEMP_STORE_CUSTOM_ACTION, ...)
addListener(EventTypes.CALLBACK_INAPP_SEEN, ...)
addListener(EventTypes.CALLBACK_FOREGROUND_PUSH, ...)
- Interfaces
- Enums
initialize(_options: { partnerId: string; appGroup?: string; quietPermission?: boolean; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ partnerId: string; appGroup?: string; quietPermission?: boolean; } |
Returns: Promise<{}>
setPhoneAsIdentifier(_options: { phone: string; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ phone: string; } |
Returns: Promise<{}>
setEmailIdentifier(_options: { email: string; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ email: string; } |
Returns: Promise<{}>
setUserIdAsIdentifier(_options: { uuid: string; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ uuid: string; } |
Returns: Promise<{}>
visitHomePage() => Promise<{}>
Returns: Promise<{}>
visitListingPage(_options: { taxonomy: string[]; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ taxonomy: string[]; } |
Returns: Promise<{}>
visitCartPage(_options: { products: InsiderProduct[]; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ products: InsiderProduct[]; } |
Returns: Promise<{}>
visitProductDetailPage(_options: { product: InsiderProduct; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ product: InsiderProduct; } |
Returns: Promise<{}>
setGDPRConsent(_options: { consent: boolean; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ consent: boolean; } |
Returns: Promise<{}>
setActiveForegroundPushView() => Promise<{}>
Returns: Promise<{}>
receivedNotification(_options: { notification: PushNotificationSchema; }) => Promise<{}>
Param | Type |
---|---|
_options |
{ notification: PushNotificationSchema; } |
Returns: Promise<{}>
addListener(eventName: EventTypes.CALLBACK_NOTIFICATION_OPEN, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName |
EventTypes.CALLBACK_NOTIFICATION_OPEN |
listenerFunc |
(data: any) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: EventTypes.CALLBACK_INAPP_BUTTON_CLICK, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName |
EventTypes.CALLBACK_INAPP_BUTTON_CLICK |
listenerFunc |
(data: any) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: EventTypes.CALLBACK_TEMP_STORE_PURCHASE, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName |
EventTypes.CALLBACK_TEMP_STORE_PURCHASE |
listenerFunc |
(data: any) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: EventTypes.CALLBACK_TEMP_STORE_ADDED_TO_CART, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName |
EventTypes.CALLBACK_TEMP_STORE_ADDED_TO_CART |
listenerFunc |
(data: any) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: EventTypes.CALLBACK_TEMP_STORE_CUSTOM_ACTION, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName |
EventTypes.CALLBACK_TEMP_STORE_CUSTOM_ACTION |
listenerFunc |
(data: any) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: EventTypes.CALLBACK_INAPP_SEEN, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName |
EventTypes.CALLBACK_INAPP_SEEN |
listenerFunc |
(data: any) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: EventTypes.CALLBACK_FOREGROUND_PUSH, listenerFunc: () => void) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName |
EventTypes.CALLBACK_FOREGROUND_PUSH |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Prop | Type | Description | Since |
---|---|---|---|
title |
string |
The notification title. | 1.0.0 |
subtitle |
string |
The notification subtitle. | 1.0.0 |
body |
string |
The main text payload for the notification. | 1.0.0 |
id |
string |
The notification identifier. | 1.0.0 |
tag |
string |
The notification tag. Only available on Android (from push notifications). | 4.0.0 |
badge |
number |
The number to display for the app icon badge. | 1.0.0 |
notification |
any |
It's not being returned. | 1.0.0 |
data |
any |
Any additional data that was included in the push notification payload. | 1.0.0 |
click_action |
string |
The action to be performed on the user opening the notification. Only available on Android. | 1.0.0 |
link |
string |
Deep link from the notification. Only available on Android. | 1.0.0 |
group |
string |
Set the group identifier for notification grouping. Only available on Android. Works like threadIdentifier on iOS. |
1.0.0 |
groupSummary |
boolean |
Designate this notification as the summary for an associated group . Only available on Android. |
1.0.0 |
Prop | Type |
---|---|
remove |
() => Promise<void> |
Members | Value |
---|---|
CALLBACK_NOTIFICATION_OPEN |
'notification_open' |
CALLBACK_INAPP_BUTTON_CLICK |
'inapp_button_click' |
CALLBACK_TEMP_STORE_PURCHASE |
'temp_store_purchase' |
CALLBACK_TEMP_STORE_ADDED_TO_CART |
'temp_store_added_to_cart' |
CALLBACK_TEMP_STORE_CUSTOM_ACTION |
'temp_store_custom_action' |
CALLBACK_INAPP_SEEN |
'inapp_seen' |
CALLBACK_FOREGROUND_PUSH |
"foreground_push" |
The InsiderEvent
class represents an internal event. It allows the addition of parameters of different types to this event.
-
constructor(eventName: string)
- Creates a new instance of
InsiderEvent
with the provided event name.
- Creates a new instance of
-
addParameterWithString(key: string, value: string): InsiderEvent
- Adds a parameter with a string value.
-
addParameterWithInt(key: string, value: number): InsiderEvent
- Adds a parameter with an integer value.
-
addParameterWithDouble(key: string, value: number): InsiderEvent
- Adds a parameter with a double value.
-
addParameterWithBoolean(key: string, value: boolean): InsiderEvent
- Adds a parameter with a boolean value.
-
addParameterWithDate(key: string, value: string): InsiderEvent
- Adds a parameter with a date value.
-
addParameterWithArray(key: string, value: string[]): InsiderEvent
- Adds a parameter with an array of strings value.
The InsiderProduct
class represents an internal product. It allows the addition of both required and optional parameters to this product.
-
constructor(productId: string, productName: string, taxonomy: string[], imageURL: string, price: number, currency: string)
- Creates a new instance of
InsiderProduct
with the provided required parameters.
- Creates a new instance of
-
Methods to add parameters with different value types, similar to the
InsiderEvent
class. -
Methods to set optional parameters of the product:
setColor(color: string): InsiderProduct
setVoucherName(voucherName: string): InsiderProduct
setVoucherDiscount(voucherDiscount: number): InsiderProduct
setPromotionName(promotionName: string): InsiderProduct
setPromotionDiscount(promotionDiscount: number): InsiderProduct
setGroupcode(groupcode: string): InsiderProduct
setSize(size: string): InsiderProduct
setSalePrice(salePrice: number): InsiderProduct
setShippingCost(shippingCost: number): InsiderProduct
setQuantity(quantity: number): InsiderProduct
setStock(stock: number): InsiderProduct
setSubCategory(subCategory: string): InsiderProduct