Date Vs Nsdate Swift 4 Appstore Upload Issue
This section shows y'all how to how to track custom events, enrich user profiles, and ship push notifications with the CleverTap SDK in your iOS app. If y'all have not already completed the iOS SDK Quick Start Guide, complete that first before following the steps in this department. The quick beginning guide shows you lot how to install the CleverTap SDK, track your first user event, and see this information within the CleverTap dashboard.
CleverTap stores the user's demographic data (gender, age, location), app and website interaction events, entrada visits, and transaction history to give yous a consummate picture of every user.
A user profile is automatically created for every user launching your mobile awarding – whether logged in or non.
Initially, the user profile starts out as "Anonymous" – which ways that the profile does not yet contain any identifiable information about the user. Yous can cull to enrich the profile with attributes such every bit proper name, age, and client id.
CleverTap provides pre-defined profile properties such as name, phone, gender, historic period and so on to represent well know properties associated with a profile. It is strongly recommended to use these standard holding names. A list of all pre-defined property names is available here. In improver, nosotros also back up arbitrary single and multi-value profile properties.
Examples of updating profile properties for a project written in Objective-C are documented below.
// each of the below mentioned fields are optional // if set, these populate demographic information in the Dashboard NSDateComponents *dob = [[NSDateComponents alloc] init]; dob.day = 24; dob.month = 5; dob.year = 1992; NSDate *d = [[NSCalendar currentCalendar] dateFromComponents:dob]; NSDictionary *contour = @{ @"Name": @"Jack Montana", // String @"Identity": @61026032, // String or number @"Email": @"[email protected]", // Electronic mail address of the user @"Phone": @"+14155551234", // Phone (with the country code, starting with +) @"Gender": @"M", // Can be either Grand or F @"Employed": @"Y", // Can be either Y or North @"Educational activity": @"Graduate", // Can be either Graduate, College or School @"Married": @"Y", // Can be either Y or Due north @"DOB": d, // Engagement of Nativity. An NSDate object @"Age": @28, // Not required if DOB is set @"Tz": @"Asia/Kolkata", //an abbreviation such as "PST", a full name such equally "America/Los_Angeles", //or a custom ID such as "GMT-viii:00" @"Photo": @"www.foobar.com/image.jpeg", // URL to the Image // optional fields. controls whether the user will be sent electronic mail, push etc. @"MSG-e-mail": @NO, // Disable email notifications @"MSG-push": @YES, // Enable push notifications @"MSG-sms": @NO // Disable SMS notifications @"MSG-dndPhone": @YES, // Opt out phone number from SMS notifications @"MSG-dndEmail": @Yes, // Opt out email from email notifications }; [[CleverTap sharedInstance] profilePush:profile]; NSDictionary *profile = @{ @"Customer Type": @"Silver", @"Prefered Language": @"English", }; [[CleverTap sharedInstance] profilePush:profile]; /** * Data types: * The value of a belongings can be of type NSDate, a NSNumber, a NSString, or a BOOL. */ // To set a multi-value belongings [[CleverTap sharedInstance] profileSetMultiValues:@[@"pocketbook", @"shoes"] forKey:@"myStuff"]; // To add an boosted value(s) to a multi-value property [[CleverTap sharedInstance] profileAddMultiValue:@"glaze" forKey:@"myStuff"]; // or [[CleverTap sharedInstance] profileAddMultiValues:@[@"socks", @"scarf"] forKey:@"myStuff"]; //To remove a value(due south) from a multi-value property [[CleverTap sharedInstance] profileRemoveMultiValue:@"handbag" forKey:@"myStuff"]; [[CleverTap sharedInstance] profileRemoveMultiValues:@[@"shoes", @"coat"] forKey:@"myStuff"]; //To remove the value of a property (scalar or multi-value) [[CleverTap sharedInstance] profileRemoveValueForKey:@"myStuff"]; Examples of updating profile properties for a project written in Swift are documented below.
// each of the below mentioned fields are optional // if set, these populate demographic information in the Dashboard let dob = NSDateComponents() dob.day = 24 dob.calendar month = five dob.year = 1992 let d = NSCalendar.currentCalendar().dateFromComponents(dob) allow profile: Dictionary<Cord, AnyObject> = [ "Name": "Jack Montana", // String "Identity": 61026032, // String or number "Email": "[email protected]", // E-mail address of the user "Phone": "+14155551234", // Phone (with the country lawmaking, starting with +) "Gender": "1000", // Tin can exist either M or F "Employed": "Y", // Can be either Y or N "Teaching": "Graduate", // Can exist either School, College or Graduate "Married": "Y", // Can exist either Y or N "DOB": d!, // Date of Nascence. An NSDate object "Age": 28, // Non required if DOB is set "Tz":"Asia/Kolkata", //an abbreviation such as "PST", a full name such as "America/Los_Angeles", //or a custom ID such every bit "GMT-8:00" "Photo": "www.foobar.com/prototype.jpeg", // URL to the Epitome // optional fields. controls whether the user will exist sent electronic mail, button etc. "MSG-email": false, // Disable email notifications "MSG-push": true, // Enable push notifications "MSG-sms": false // Disable SMS notifications "MSG-dndPhone": true, // Opt out telephone number from SMS notifications "MSG-dndEmail": @YES, // Opt out electronic mail from email notifications ] CleverTap.sharedInstance()?.profilePush(profile) allow profile: Dictionary<String, AnyObject> = [ "Customer Type": "Silver", "Prefered Linguistic communication": "English" ] CleverTap.sharedInstance()?.profilePush(profile) /** * Data types: * The value of a property can exist of type NSDate, a Number, a Cord, or a Bool. */ // To gear up a multi-value property CleverTap.sharedInstance()?.profileSetMultiValues(["pocketbook", "shoes"], forKey: "myStuff") // To add an additional value(s) to a multi-value belongings CleverTap.sharedInstance()?.profileAddMultiValue("coat", forKey: "myStuff") // or CleverTap.sharedInstance()?.profileAddMultiValues(["socks", "scarf"], forKey: "myStuff") //To remove a value(s) from a multi-value property CleverTap.sharedInstance()?.profileRemoveMultiValue("purse", forKey: "myStuff") CleverTap.sharedInstance()?.profileRemoveMultiValues(["shoes", "glaze"], forKey: "myStuff") //To remove the value of a holding (scalar or multi-value) CleverTap.sharedInstance()?.profileRemoveValueForKey("myStuff") CleverTap provides easy means to enrich the user profile with information from sources, such as Facebook. Yous can also store custom attributes in a user profile. These attributes can later be used to segment users.
You tin can opt-out a user or a telephone number.
-
To opt-out a specific user when multiple users share the same phone number, yous tin disable SMS for a specific user. Set the MSG-sms flag to imitation and the specified user stops receiving SMS. However, all other users sharing the number go on to receive letters if they accept non opted out.
-
To opt-out a telephone number and all the users associated with it, ready the MSG-dndPhone flag to true.
You can opt-out a user or an electronic mail address.
-
To opt-out a specific user when multiple users share the aforementioned email address, you lot can disable electronic mail for a specific user. Prepare the MSG-e-mail flag to faux and the specified user stops receiving email. Nonetheless, all other users sharing the e-mail accost continue to receive messages if they have not opted out.
-
To opt-out an electronic mail and all the users associated with information technology, set the MSG-dndEmail flag to truthful.
A User Event is an event that a user takes in your mobile application. CleverTap records the event on the User Profile, using an Outcome Name and optional associated key:value-based Outcome Properties. You can then segment users, target and personalize messaging based on both the Issue Proper noun and specific Event Properties.
An example of recording a User Event chosen Product Viewed.
// upshot without properties [[CleverTap sharedInstance] recordEvent:@"Product viewed"]; // consequence without properties CleverTap.sharedInstance()?.recordEvent("Production viewed") An case of recording a User Issue called Product Viewed with Backdrop.
// event with backdrop NSDictionary *props = @{ @"Product proper noun": @"Casio Chronograph Scout", @"Category": @"Mens Accessories", @"Price": @59.99, @"Date": [NSDate appointment] }; [[CleverTap sharedInstance] recordEvent:@"Product viewed" withProps:props]; /** * Data types: * The value of a property can be of blazon NSDate, a NSNumber, a NSString, or a BOOL. * * NSDate object: * When a property value is of type NSDate, the date and time are both recorded to the second. * This can be subsequently used for targeting scenarios. * For e.g. if you are recording the time of the flying as an effect belongings, * you can ship a message to the user just before their flying takes off. */ // event with properties let props = [ "Product name": "Casio Chronograph Watch", "Category": "Mens Accessories", "Toll": 59.99, "Date": NSDate() ] CleverTap.sharedInstance()?.recordEvent("Production viewed", withProps: props) /** * Data types: * The value of a property tin can be of type NSDate, a Number, a Cord, or a Bool. * * NSDate object: * When a property value is of blazon NSDate, the date and time are both recorded to the second. * This can exist later used for targeting scenarios. * For e.one thousand. if y'all are recording the time of the flight as an outcome property, * yous can send a message to the user simply earlier their flight takes off. */ For an case of how to record a custom event from a watchOS app, meet hither.
For an example of recording an consequence from an App Extension, see here.
Events aid you understand how your users interact with your app. CleverTap tracks sure common User Events automatically, while giving you the flexibility to tape business organization specific events.
If yous automatically integrated the SDK in the quick kickoff guide, you have already enabled push notification support. If you have not yet, follow the steps below.
CleverTap using the SDK is capable of sending button notifications to your users using the dashboard. To enable this back up, when your app delegate receives the awarding:didRegisterForRemoteNotificationsWithDeviceToken: message, include a telephone call to CleverTap setPushToken: as follows.
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[CleverTap sharedInstance] setPushToken:deviceToken]; } func awarding(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { CleverTap.sharedInstance()?.setPushToken(deviceToken) } The above will salvage the user's APNS token with CleverTap. This token is used to send push notifications.
Required for CleverTap iOS SDK five.3.one.seven and below and Transmission Integration:
iOS 10 has introduced the UNUserNotificationCenterDelegate for handling notifications. Implementation is optional, just if you practise implement the Delegate, delight note that, whether or not you have used automated integration, if you wish CleverTap to rails notification opens and fire attached deep links, you must manually phone call the SDK as follows.
/** For iOS 10 and above - Background **/ - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { /** For iOS 10 and to a higher place. Apply this method to perform the tasks associated with your app's custom actions. When the user responds to a notification, the system calls this method with the results. You lot use this method to perform the task associated with that action, if at all. At the end of your implementation, you must telephone call the completionHandler block to let the system know that you are washed processing the notification. Yous specify your app'due south notification types and custom deportment using UNNotificationCategory and UNNotificationAction objects. You create these objects at initialization time and annals them with the user notification middle. Even if you register custom actions, the action in the response parameter might bespeak that the user dismissed the notification without performing any of your deportment. If yous do non implement this method, your app never responds to custom actions. see https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter?language=objc **/ // Skip this line if you have opted for auto-integrate. If yous wish CleverTap to record the notification open and fire any deep links contained in the payload. [[CleverTap sharedInstance] handleNotificationWithData:response.notification.asking.content.userInfo]; completionHandler(); } /** For iOS 10 and higher up - Groundwork **/ func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { /** Use this method to perform the tasks associated with your app's custom deportment. When the user responds to a notification, the system calls this method with the results. Yous utilise this method to perform the task associated with that action, if at all. At the end of your implementation, y'all must call the completionHandler block to permit the arrangement know that you are washed processing the notification. You specify your app's notification types and custom deportment using UNNotificationCategory and UNNotificationAction objects. You create these objects at initialization time and register them with the user notification center. Even if you annals custom actions, the action in the response parameter might indicate that the user dismissed the notification without performing any of your actions. If you do not implement this method, your app never responds to custom deportment. encounter https://developer.apple tree.com/reference/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter **/ // if you wish CleverTap to record the notification open and burn down whatever deep links contained in the payload. Skip this line if you lot accept opted for machine-integrate. CleverTap.sharedInstance().handleNotification(withData: response.notification.request.content.userInfo) completionHandler() } When your app is not running or is in the background, the to a higher place method volition track notification opens and burn down fastened deep links. But if you lot want CleverTap to continue to fire attached deep links when in the foreground, you must manually call the SDK every bit follows.
/** For iOS 10 and above - Foreground **/ - (void)userNotificationCenter:(UNUserNotificationCenter *)eye willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{ /** Use this method to perform the tasks associated with your app's custom deportment. When the user responds to a notification, the arrangement calls this method with the results. You apply this method to perform the task associated with that action, if at all. At the end of your implementation, yous must call the completionHandler block to let the system know that you lot are done processing the notification. Y'all specify your app'southward notification types and custom actions using UNNotificationCategory and UNNotificationAction objects. You create these objects at initialization time and register them with the user notification centre. Even if yous annals custom actions, the activity in the response parameter might indicate that the user dismissed the notification without performing any of your actions. If y'all do not implement this method, your app never responds to custom actions. run into https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter?language=objc **/ // if you lot wish CleverTap to record the notification open and fire any deep links contained in the payload [[CleverTap sharedInstance]handleNotificationWithData:notification.request.content.userInfo openDeepLinksInForeground: YES]; completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); } /** For iOS 10 and above - Foreground**/ func userNotificationCenter(_ heart: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) { /** Use this method to perform the tasks associated with your app'due south custom deportment. When the user responds to a notification, the system calls this method with the results. You employ this method to perform the task associated with that action, if at all. At the end of your implementation, y'all must call the completionHandler block to allow the organization know that you are done processing the notification. Y'all specify your app's notification types and custom actions using UNNotificationCategory and UNNotificationAction objects. You create these objects at initialization fourth dimension and register them with the user notification center. Even if you register custom actions, the action in the response parameter might betoken that the user dismissed the notification without performing any of your deportment. If you do not implement this method, your app never responds to custom actions. see https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter **/ print("APPDELEGATE: didReceiveResponseWithCompletionHandler \(response.notification.request.content.userInfo)") // If yous wish CleverTap to record the notification click and fire any deep links contained in the payload. CleverTap.sharedInstance()?.handleNotification(withData: notification.request.content.userInfo, openDeepLinksInForeground: true) completionHandler([.badge, .audio, .warning]) } To get the callback on the click of the Push button Notifications, cheque that your form implements the CleverTapPushNotificationDelegate consul and then employ the following method to handle the user-selected actions from Button notifications:
- (void)pushNotificationTappedWithCustomExtras:(NSDictionary *)customExtras { NSLog(@"Push Notification Tapped with Custom Extras: %@", customExtras); ... } func pushNotificationTapped(withCustomExtras customExtras: [AnyHashable : Any]!) { impress("Push button Notification Tapped with Custom Extras: \(customExtras)") ... } ###ane. APNS Device Token Does Non Match The Specified Topic
Apple Push button Notification service (APNs) returns this fault when the device token doesn't match the specified topic.
In the context of CleverTap, you will get this fault when y'all try to send the notification with a wrong certificate. Check that yous use a product certificate for the production surroundings. This error is acquired because of incorrect configurations.
Check the provisioning profile used to deploy the app and send the device token to the CleverTap dashboard. To avert this error, the "App bundle ID" of the provisioning profile and the CleverTap push certificate (p12 document) must friction match.
The Push notification delivery to the target fails because the device token is inactive for the specified topic. If the device token is not valid/inactive you may have to await till the user installs the app over again. Y'all can then starting time sending notifications.
The topic is currently the packet identifier of the target application on an iOS device. The "APNS Topic Disallowed" error appears when y'all specify the incorrect "App Parcel ID" in the Account Settings. For more data, meet Apple documentation.
To resolve this mistake, check the value of the "App Bundle ID" and "APNs button mode" that you have configured in the CleverTap Dashboard under Push Settings.
Y'all are temporarily blacklisted from sending push notifications to the device, which can be due to sending bad tokens. The push notification volition not be delivered for some elapsing.
The notification to the device sent from CleverTap failed to deliver due to either of the following reasons
- The app was uninstalled and the token is no longer valid.
- You lot accept sent likewise many notifications in short duration to the same device.
If the user has uninstalled the app and then you may take to wait until the user installs the app again before the user can receive your notifications.
For more info about APNs, come across Treatment Notification Responses from APNs.
The push notification delivery to the target device has failed due to an invalid token. The APNs bad device token error occurs when at that place is a mismatch between the APNs push mode on your app and the CleverTap dashboard.
For example, yous have set the APNs push mode in your app to the "development" phase and in the "CleverTap" dashboard yous have set up to "production" stage. To check your CleverTap dashboard APNs push fashion: Navigate to Settings > Engage > Mobile Push button> iOS.
You tin now raise and record push notifications delivered onto your users' iOS devices.
CleverTap SDK v3.5.0 and above supports raising Push button Impressions for button campaigns.
To enhance Button Impressions for iOS, the Notification Service Extension must be included.
Notification Service Extension is a separate and distinct binary embedded in your app bundle. Prior to displaying a new push notification, the system volition telephone call your Notification Service Extension to allow you to call the Notification Viewed method for your Application.
Note
Push Impressions are not raised if the Notification Service Extension is non included in your app packet.
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)asking withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { self.contentHandler = contentHandler; self.bestAttemptContent = [request.content mutableCopy]; // While running the Application add CleverTap Business relationship ID and Business relationship token in your .plist file // call to record the Notification viewed [[CleverTap sharedInstance] recordNotificationViewedEventWithData:asking.content.userInfo]; [super didReceiveNotificationRequest:request withContentHandler:contentHandler]; } override func didReceive(_ asking: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { // While running the Application add CleverTap Account ID and Account token in your .plist file // telephone call to record the Notification viewed CleverTap.sharedInstance()?.recordNotificationViewedEvent(withData: request.content.userInfo) super.didReceive(request, withContentHandler: contentHandler) }
Dummy Contour Cosmos
If the
Notification viewedmethod is not called correctly, it will create a new profile in CleverTap with only this consequence. This will create a dummy contour with no other event and will not be mapped to the profile from which the Push Impressions upshot was raised.To avoid the creation of a new user contour while calling the Notification Viewed method from your Application, you must pass the Identity/ Email to CleverTap in the Notification Service Class or yous tin can telephone call recordNotificationViewedEvent API from your Principal Application.
Sending notifications via APNS
- Include the mutable-content flag in your apns payload (this key must exist present in the apns payload or the system will non phone call your app extension)
The CleverTap SDK allows you to show In-App notifications to your users. You can design in-app notifications right from the dashboard, without writing a single line of lawmaking. There is no lawmaking required for this feature
Note: not applicable within App Extensions and watchOS apps.
Javascript back up in In-App Notifications
CleverTap iOS SDK v3.v.0 and above supports embedding Javascript code inside Custom In-Apps. To make sure your Javascript lawmaking works on the app, while creating the InApp campaign, select the checkbox for Enabling javascript during the In-App campaign cosmos
All methods explained with examples below
//Recording a User Upshot called Product Viewed in JS enabled custom in-apps. var props = {foo: 'xyz', lang: 'French'}; var message = { activity:'recordEventWithProps', event:'Product Viewed', props: props}; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ // Telephone call iOS interface window.webkit.messageHandlers.clevertap.postMessage(message); } //Updating profile backdrop of the User in JS enabled custom in-apps. var props = {foo: 'xyz', lang: 'French'}; var message = { activity:'profilePush', properties: props}; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ // Call iOS interface window.webkit.messageHandlers.clevertap.postMessage(message); } //Setting a user profile var bulletin = { action: 'profileSetMultiValues', values: ['bag', 'kitkat'], key: 'myStuff' }; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ window.webkit.messageHandlers.clevertap.postMessage(message); } //Add multi value var message = {activity: 'profileAddMultiValue', value: 'coat', key: 'myStuff'}; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ window.webkit.messageHandlers.clevertap.postMessage(message); } //Add multi values var message = {activeness: 'profileAddMultiValues', values: ['pocketbook', 'kitkat', 'Wine'], key: 'myStuff'}; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ window.webkit.messageHandlers.clevertap.postMessage(message); } //Remove value for central var message = {action: 'profileRemoveValueForKey', cardinal: 'myStuff' }; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ window.webkit.messageHandlers.clevertap.postMessage(bulletin); } //Remove multi values for key var message = {action: 'profileRemoveMultiValues', values: ['scarf', 'knife'], cardinal: 'myStuff'}; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ window.webkit.messageHandlers.clevertap.postMessage(message); } //Remove multi Value var message = {action: 'profileRemoveMultiValue', value: 'bag', key: 'myStuff'}; if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap){ window.webkit.messageHandlers.clevertap.postMessage(message); } //Record Charged Event const chargeDetails = { "Amount" : 300, "Payment mode": "Credit Card", "Charged ID": 24052013 }; const items = [{ "Category": "books", "Book name": "The Millionaire next door", "Quantity": one },{ "Category": "books", "Book name": "The Millionaire previous door", "Quantity": 5 }]; const bulletin = { action:'recordChargedEvent', chargeDetails: chargeDetails, items: items }; if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.clevertap) { window.webkit.messageHandlers.clevertap.postMessage(message); }
Inline Media
To add together inline media support in custom HTML for in-app notifications, add the key playsinline with value equally i or true as a query parameter in your media URL For case, https://www.youtube.com/picket?v=RUvrypIAPbg?playsinline=1. This functionality is available for CleverTap iOS SDK 3.vii.2 and in a higher place.
iOS SDK v3.seven.1 and in a higher place supports callback on the click of InApp Notification Buttons by returning a Map of Key-Value pairs. To utilise this, make sure your class implements the CleverTapInAppNotificationDelegate and apply the following method to handle user-selected actions from InApp notifications:
- (void)inAppNotificationButtonTappedWithCustomExtras:(NSDictionary *)customExtras { NSLog(@"inAppNotificationButtonTappedWithCustomExtras:%@", customExtras); ... } func inAppNotificationButtonTapped(withCustomExtras customExtras: [AnyHashable : Any]!) { print("In-App Push button Tapped with custom extras:", customExtras ?? ""); } For CleverTap iOS SDK 3.ten.0 and above, you can suspend, discard, or resume in-app notifications.
Note
The CleverTap SDK automatically resumes displaying the in-app notification later every new session.
You can control the in-app notifications in the following ways:
The suspendInAppNotifications method suspends and saves in-app notifications until the resumeInAppNotifications method is called for the electric current session.
CleverTap.sharedInstance()?.suspendInAppNotifications() #import <CleverTapSDK/CleverTap+InAppNotifications.h> [[CleverTap sharedInstance] suspendInAppNotifications]; The discardInAppNotifications method discards in-app notifications until the resumeInAppNotifications method is called for the electric current session.
CleverTap.sharedInstance()?.discardInAppNotifications() #import <CleverTapSDK/CleverTap+InAppNotifications.h> [[CleverTap sharedInstance] discardInAppNotifications]; The resumeInAppNotifications method resumes displaying in-app notifications.
CleverTap.sharedInstance()?.resumeInAppNotifications() #import <CleverTapSDK/CleverTap+InAppNotifications.h> [[CleverTap sharedInstance] resumeInAppNotifications]; If you call this the resumeInAppNotifications method after the suspendInAppNotifications() method, then the CleverTap SDK displays all the queued in-app notifications and too resumes the new in-app notifications.
Note
The
showInAppNotificationIfAnymethod will be deprecated soon. Use theresumeInAppNotificationsmethod to manually display the pending in-app notifications.
For CleverTap iOS SDK 3.ten.0 and above, y'all tin can implement custom handling for URLs of in-app notification CTAs, push notifications, and app Inbox letters.
Check that your course conforms to the CleverTapURLDelegate protocol by beginning calling setURLDelegate. Use the following protocol method shouldHandleCleverTap(_ : forChannel:) to handle URLs received from channels such as in-app notification CTAs, push button notifications, and app Inbox letters:
// Set the URL Consul CleverTap.sharedInstance()?.setUrlDelegate(self) // CleverTapURLDelegate method public func shouldHandleCleverTap(_ url: URL?, for aqueduct: CleverTapChannel) -> Bool { print("Handling URL: \(url!) for channel: \(channel)") return true } #import <CleverTapSDK/CleverTapURLDelegate.h> // Set up the URL Delegate [[CleverTap sharedInstance]setUrlDelegate:self]; // CleverTapURLDelegate method - (BOOL)shouldHandleCleverTapURL:(NSURL *)url forChannel:(CleverTapChannel)channel { NSLog(@"Handling URL: \(%@) for channel: \(%d)", url, aqueduct); return YES; } Deep links are a way of launching a native app and providing additional data telling information technology do some specific event or show specific content. CleverTap automatically tracks universal links that open your application. If you take universal (deep) links coming to your app, you tin can capture the incoming UTM parameters easily. Call handleOpenURL:sourceApplication: when the awarding:openURL:sourceApplication:annotation: bulletin is sent to your app delegate.
- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)notation { [[CleverTap sharedInstance] handleOpenURL:url sourceApplication:sourceApplication]; render YES; } - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { [[CleverTap sharedInstance] handleOpenURL:url sourceApplication:nil]; render YES; } - (void)openURL:(NSURL*)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion { [[CleverTap sharedInstance] handleOpenURL:url sourceApplication:nil]; if (completion) { completion(Yeah); } } func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { CleverTap.sharedInstance()?.handleOpenURL(url, sourceApplication: sourceApplication) return truthful } // Swift 3 func awarding(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Whatsoever] = [:]) -> Bool { CleverTap.sharedInstance()?.handleOpen(url, sourceApplication: nil) return true } func open(_ url: URL, options: [String : Whatever] = [:], completionHandler completion: ((Bool) -> Swift.Void)? = aught) { CleverTap.sharedInstance()?.handleOpen(url, sourceApplication: nil) completion?(false) } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { [CleverTap setLocation: newLocation.coordinate]; } func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) { CleverTap.setLocation(newLocation.coordinate) } - The CleverTap SDK 3.4.0 and above, allows you lot to create App Inbox notifications for your users.
- Yous tin use the App Inbox provided by CleverTap or create your own
- You can blueprint App Inbox notifications right from the dashboard
Note: not applicable for tvOS and watchOS apps.
- You have to import the CleverTap Inbox Header
- Initialize the CleverTap App Inbox Method
#import <CleverTapSDK/CleverTap+Inbox.h> //Initialize the CleverTap App Inbox [[CleverTap sharedInstance] initializeInboxWithCallback:^(BOOL success) { int messageCount = (int)[[CleverTap sharedInstance] getInboxMessageCount]; int unreadCount = (int)[[CleverTap sharedInstance] getInboxMessageUnreadCount]; NSLog(@"Inbox Message: %d/%d", messageCount, unreadCount); }]; import CleverTapSDK //Initialize the CleverTap App Inbox CleverTap.sharedInstance()?.initializeInbox(callback: ({ (success) in let messageCount = CleverTap.sharedInstance()?.getInboxMessageCount() let unreadCount = CleverTap.sharedInstance()?.getInboxMessageUnreadCount() print("Inbox Bulletin:\(String(describing: messageCount))/\(String(describing: unreadCount)) unread") })) - Past default, App Inbox styling will exist CleverTap'due south default colors and font
- Y'all tin choose to change the styling every bit shown below
// config the style of App Inbox Controller CleverTapInboxStyleConfig *style = [[CleverTapInboxStyleConfig alloc] init]; style.backgroundColor = [UIColor blueColor]; fashion.messageTags = @[@"tag1", @"tag2"]; manner.navigationBarTintColor = [UIColor blueColor]; style.navigationTintColor = [UIColor blueColor]; style.tabUnSelectedTextColor = [UIColor blueColor]; fashion.tabSelectedTextColor = [UIColor blueColor]; style.tabSelectedBgColor = [UIColor blueColor]; way.firstTabTitle = @"My Start Tab"; CleverTapInboxViewController *inboxController = [[CleverTap sharedInstance] newInboxViewControllerWithConfig:mode andDelegate:self]; if (inboxController) { UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:inboxController]; [self presentViewController:navigationController animated:Yeah completion:aught]; } // config the mode of App Inbox Controller let fashion = CleverTapInboxStyleConfig.init() style.title = "App Inbox" style.backgroundColor = UIColor.blue() mode.messageTags = ["tag1", "tag2"] style.navigationBarTintColor = UIColor.blue() manner.navigationTintColor = UIColor.blueish() way.tabUnSelectedTextColor = UIColor.blue() way.tabSelectedTextColor = UIColor.blue() way.tabSelectedBgColor = UIColor.bluish() fashion.firstTabTitle = "My Commencement Tab" if let inboxController = CleverTap.sharedInstance()?.newInboxViewController(with: style, andDelegate: self) { allow navigationController = UINavigationController.init(rootViewController: inboxController) self.nowadays(navigationController, animated: true, completion: nil) } - You can cull to create your own App Inbox by calling the following APIs
//Initialize App Inbox - (void)initializeInboxWithCallback:(CleverTapInboxSuccessBlock _Nonnull)callback; //Get Inbox Message Count - (NSUInteger)getInboxMessageCount; //Get Inbox Unread Count - (NSUInteger)getInboxMessageUnreadCount; //Go All messages - (NSArray<CleverTapInboxMessage *> * _Nonnull )getAllInboxMessages; //Get only Unread letters - (NSArray<CleverTapInboxMessage *> * _Nonnull )getUnreadInboxMessages; //Get message object belonging to the given message id only. Bulletin id must be a Cord - (CleverTapInboxMessage * _Nullable )getInboxMessageForId:(NSString *)messageId; //Delete message from the Inbox. Message id must exist a String - (void)deleteInboxMessage:(CleverTapInboxMessage * _Nonnull )bulletin; //Mark Bulletin equally Read - (void)markReadInboxMessage:(CleverTapInboxMessage * _Nonnull) message; //Callback on Inbox Message update/delete/read (any activeness) - (void)registerInboxUpdatedBlock:(CleverTapInboxUpdatedBlock _Nonnull)cake; //Record Notification Viewed for App Inbox. - (void)recordInboxNotificationViewedEventForID:(NSString * _Nonnull)messageId; // Record Notification Clicked for App Inbox. - (void)recordInboxNotificationClickedEventForID:(NSString * _Nonnull)messageId; //Mark Bulletin as Read. Message id must be a String - (void)markReadInboxMessageForID:(NSString * _Nonnull)messageId; //Delete message from the Inbox. Message id must be a String - (void)deleteInboxMessageForID:(NSString * _Nonnull)messageId; To get the callback on the click of the App Inbox Notification, check that your form implements the CleverTapInboxViewControllerDelegate and utilize the post-obit method to handle user-selected actions from InApp notifications:
-(void)messageDidSelect:(CleverTapInboxMessage *)message atIndex:(int)index withButtonIndex:(int)buttonIndex { // This is called when an inbox message is clicked(tapped or call to action) CleverTapInboxMessageContent *content = (CleverTapInboxMessageContent*)message.content[index]; ... } func messageDidSelect(_ message: CleverTapInboxMessage, at index: Int32, withButtonIndex buttonIndex: Int32) { // This is called when an inbox bulletin is clicked(tapped or call to activeness) ... } iOS SDK v3.vii.one and above supports callback on the click of App Inbox Notification Buttons past returning a map of Key-Value pairs. Utilise the following method:
- (void)messageButtonTappedWithCustomExtras:(NSDictionary *)customExtras { NSLog(@"App Inbox Button Tapped with custom extras::%@", customExtras); } func messageButtonTapped(withCustomExtras customExtras: [AnyHashable : Any]?) { print("App Inbox Push Tapped with custom extras: ", customExtras ?? ""); } Past default, CleverTap logs are set to CleverTapLogLevel.info. During development, we recommend that yous set the SDK to DEBUG manner, in order to log warnings or other important messages to the iOS logging system. This can exist washed past setting the debug level to CleverTapLogLevel.debug. If you want to disable CleverTap logs for production surround, you can set up the debug level to CleverTapLogLevel.off.
#ifdef DEBUG [CleverTap setDebugLevel:CleverTapLogDebug]; #else [CleverTap setDebugLevel:CleverTapLogOff];
Post a Comment for "Date Vs Nsdate Swift 4 Appstore Upload Issue"