Usage
Pinch
Available consents
PinchSDK.Consent.surveys
PinchSDK.Consent.analytics
PinchSDK.Consent.campaigns
PinchSDK.Consent.ads
1
2
3
4
[PinchX ConsentSurveys];
[PinchX ConsentAnalytics];
[PinchX ConsentCampaigns];
[PinchX ConsentAds];
1
2
3
4
Granting consents
PinchSDK.grant(consents: [.ads, .analytics, .campaigns, .surveys])
{ (success) in
print("grant succeeded: \(success)")
}
1
2
3
4
NSMutableArray *consents = [NSMutableArray array];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentAnalytics]]];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentSurveys]]];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentCampaigns]]];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentAds]]];
[PinchX grantWithConsents:consents onSuccess:^(BOOL success) {
if (success) ...
}];
1
2
3
4
5
6
7
8
9
Revoking consents
Revoking a consent requires an active network connection. The revoke method accepts an optional closure which returns if the given consents were successfully revoked.
PinchSDK.revoke(consents: [.ads, .analytics, .campaigns, .surveys])
{ (success) in
print("revoke succeeded: \(success)")
}
1
2
3
4
NSMutableArray *consents = [NSMutableArray array];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentAnalytics]]];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentSurveys]]];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentCampaigns]]];
[consents addObject:[NSNumber numberWithInteger:[PinchX ConsentAds]]];
[PinchX revokeWithConsents:consents onSuccess:^(BOOL success) {
if (success) ...
}];
1
2
3
4
5
6
7
8
9
Requesting bluetooth permission
A convenience method to trigger bluetooth permission dialog is provided:
PinchSDK.requestBluetoothPermission()
1
[PinchX requestBluetoothPermission];
1
Retrieve granted consents
let grantedConsents: [PinchSDK.Consent] = PinchSDK.grantedConsents
1
NSArray<NSNumber*> *consents = [PinchX grantedConsents];
1
Set IDFA/ADID
IDFA/ADID can be passed to PinchSDK by calling:
import AdSupport
PinchSDK.adid = ASIdentifierManager.shared().advertisingIdentifier
1
2
[PinchX setAdid:ASIdentifierManager.sharedManager.advertisingIdentifier];
1
Start SDK
An overloaded method accepts a list of providers to use for collection data.
PinchSDK.start(providers: [.bluetooth, .location, .motion])
1
// Start location & bluetooth
[PinchX start];
// Start location
[PinchX startLocationProvider];
// Start bluetooth
[PinchX startBluetoothProvider];
// Start motion
[PinchX startMotionProvider];
1
2
3
4
5
6
7
8
9
10
11
Note
The SDK will remember that it has been started, and subsequent calls to is unneccessary. If user clears or deletes app data, start has to be called again.
Stop SDK
An overloaded method accepts a list of providers to disable for collecting data.
If all previously granted providers are removed, SDK will be stopped.
PinchSDK.stop(providers: [.bluetooth, .location, .motion])
1
// Stop location & bluetooth
[PinchX stop];
// Stop location
[PinchX stopLocationProvider];
// Stop bluetooth
[PinchX stopBluetoothProvider];
// Stop motion
[PinchX stopBluetoothProvider];
1
2
3
4
5
6
7
8
9
10
11
Retrieve SDK status
You can check if the SDK is started by calling:
PinchSDK.isTracking {
(sdkStarted) in
print("pinch started: \(sdkStarted)")
}
1
2
3
4
[PinchX isTracking:^(BOOL sdkTracking) {
if (sdkTracking) ...
}];
1
2
3
Send demographic profile
You can send your users demographic profile to the Pinch Platform by calling:
PinchSDK.sendDemographicProfile(with: DemographicProfile(birthYear: 1995, gender: .male))
{ (success) in
print("demographic profile sent: \(success)")
}
1
2
3
4
// 0 = Unknown
// 1 = Male
// 2 = Female
[PinchX sendDemographicProfileWithBirthYear:1995 gender:1 onSuccess:^(BOOL success) {
if (success) ...
}];
1
2
3
4
5
6
7
Send custom data
You can send custom data to the Pinch Platform by calling:
PinchSDK.addCustomData(type: "type", json: ["string": "s1", "int": 1])
{ (success) in
print("custom data sent: \(success)")
}
1
2
3
4
[PinchX addCustomDataWithType:@"Purchase" json:@{@"ticketType": @"regular", @"paymentMethod": @"visa"} onSuccess:^(BOOL success) {
if (success) ...
}];
1
2
3
Note
This method performs a PUT request, replacing any previous values sent with the same type.
You can send metadata to the Pinch Platform by calling:
PinchSDK.setMetadata(type: "type", json: ["string": "s1", "int": 1])
{ (success) in
print("metadata sent: \(success)")
}
1
2
3
4
[PinchX setMetadataWithType:@"UserInfo" json:@{@"name": @"Erika Kristinsdottir", @"phone": @"049342343"} onSuccess:^(BOOL success) {
if (success) ...
}];
1
2
3
Push tokens
MessagingId is the ID used by the Pinch Platform for sending notifications to the device (eg. FCM registration id). This can be done by calling:
PinchSDK.messagingId = "<token>"
1
[PinchX setMessagingId:@"<token>"];
1
Retrieve privacy terms URL
The URL for privacy terms can be retrieved by calling:
let privacyTermsUrl: String = PinchSDK.privacyTermsUrl
1
NSString* privacyTermsUrl = [PinchX privacyTermsUrl];
1
Retrieve privacy dashboard URL
The URL for the privacy dashboard, which contains all collected data for given consent, can be retrieved by calling:
let privacyDashboardUrl: String = PinchSDK.getPrivaryDashboardUrl(for: .surveys)
1
NSString* privacyDashboardUrl = [PinchX privaryDashboardUrl];
1
Deleted collected PII & data
You can delete all PII and collected data about a user by calling this method. It requires an active internet connection and accepts an optional closure to verify if the request was successfully sent.
PinchSDK.deleteCollectedData() { (success) in
print("deletion request sent: \(success)")
}
1
2
3
[PinchX deleteCollectedDataOnSuccess:^(BOOL success) {
if (success) ...
}];
1
2
3
Pinch Messaging Center
Retrieve messages
Note
All fields in PinchMessage
except created
, expiry
and opened
is nullable.
PinchMessagingCenter.getMessages { (messages) in
for msg in messages {
}
}
1
2
3
4
5
[PinchMessagingCenter getStringifiedMessagesOnSuccess:^(NSString * _Nullable jsonString) {
// jsonString contains a stringified json array with messages. You need to deserialize this yourself.
// All fields except created, expiry and opened is nullable.
// Example payload:
// [
// {
// "url": String,
// "expireTime": Int64 (Expiry time in epoch millis),
// "timestamp": Int64 (Creatioon time in epoch millis),
// "messageTitle": String,
// "messageBody": String,
// "messageImageUrl": String,
// "deliveryId": String,
// "messageId": String,
// "opened": Bool
// }
// ]
}];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Pinch Motion Tracking
Start tracking motion
Minimum SDK version: 1.1.11
Add the following key and value to your applications Info.plist
:
<key>NSMotionUsageDescription</key>
<string>Text to show in system dialog during permission request</string>
1
2
Pinch will automatically track motion if the user has given permission for motion.
Motion data will be collected alongside location updates, which requires the location provider to be enabled.
Pinch provides a utility method to trigger the system permission dialog for motion:
PinchSDK.requestMotionPermission()
1
[PinchX requestMotionPermission];
1