Used to embed gist to an asynchronously-loaded web pages.
<iframe
width="100%"
height="350"
src="data:text/html;charset=utf-8,
// value: some information about the action - type of subscription plan, type of segment, A/B test ID. etc. Can be nil | |
// instanceId: the moment ID used to trigger the desired action. Can be nil | |
// action: definition of the action. Can be one of: http://docs.theneura.com/ios/Constants/NEngagementFeatureAction.html | |
[NeuraSDK.shared tagEngagementAttempt:"featureName" value:"ABTestId" instanceId:nil error:&err]; | |
[NeuraSDK.shared tagEngagementFeature:"featureName" action:NEngagementFeatureActionSuccess value:valueField.text instanceId:instanceIdField.text error:&err]; | |
// When error validation is not needed, the error parameter can be nil |
private func setupNotificationsSettings(alertTitle: String, alertBody: String, identifier: String, fireDate: Date, repeatInterval: NSCalendar.Unit) { | |
if #available(iOS 10.0, *) { | |
let specificDate = fireDate | |
//convert dateComponents() to Date() | |
let dateComponents = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second, .timeZone], from: specificDate) | |
var trigger: UNNotificationTrigger | |
if (repeatInterval.rawValue > 0) { |
@available(iOS 10.0, *) | |
private func getNewCategoryByIdentifier(identifier: String) -> UNNotificationCategory { | |
let tookAction = UNNotificationAction(identifier: kTookActionIdentifier, title: NSLocalizedString("Took", comment: "Took"), options: []) | |
let laterAction = UNNotificationAction(identifier: kLaterActionIdentifier, title: NSLocalizedString("Later", comment: "Took"), options: []) | |
return UNNotificationCategory(identifier: identifier, actions: [tookAction, laterAction], intentIdentifiers: [], options: []) | |
} | |
// For comparison, here is the old category usage | |
private func getCategoryByIdentifier(identifier: String) -> UIUserNotificationCategory { | |
private func registerForRemoteNotifications () { | |
if #available(iOS 10.0, *) { | |
let userNotificationType: UNAuthorizationOptions = [UNAuthorizationOptions.alert, UNAuthorizationOptions.badge, UNAuthorizationOptions.sound] | |
UNUserNotificationCenter.current().setNotificationCategories([self.getNewCategoryByIdentifier(identifier: kMorningEventIdentifier), | |
self.getNewCategoryByIdentifier(identifier: kEveningEventIdentifier), | |
self.getNewCategoryByIdentifier(identifier: kTakePillboxEventIdentifier)]) | |
UNUserNotificationCenter.current().requestAuthorization(options: userNotificationType, completionHandler: { (success:Bool, error:Error?) in | |
}) | |