{"_id":"5787837f9f5d1b0e00432f51","parentDoc":null,"user":"54aa7f3f9bb00c0b00cb899b","__v":8,"githubsync":"","project":"54aa7f773b56130b0056c86e","version":{"_id":"55781fe25129590d003ff4f7","project":"54aa7f773b56130b0056c86e","forked_from":"54aa7f773b56130b0056c871","__v":6,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z","categories":["55781fe35129590d003ff4f8","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","55781fe35129590d003ff4fb","55781fe35129590d003ff4fc","55781fe35129590d003ff4fd","55781fe35129590d003ff4fe","564bbc7e8841060d00abb2ee","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","582318b23b961a0f009516a1","594a848c9f4771001a43c959"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Developers","version_clean":"2.0.0","version":"2.0"},"category":{"_id":"55781fe35129590d003ff4fb","version":"55781fe25129590d003ff4f7","__v":11,"pages":["55781fe45129590d003ff517","55781fe45129590d003ff518","55781fe45129590d003ff519","55781fe45129590d003ff51a","55781fe45129590d003ff51b","55781fe45129590d003ff51c","55781fe45129590d003ff51d","55781fe45129590d003ff51e","55781fe45129590d003ff51f","55781fe45129590d003ff520","55781fe45129590d003ff521","55781fe45129590d003ff522","5579ab5fc7fb3f2100096fad","55f7de1660cc850d008a7a22","55f7e1fbe32e9b0d00a2d4d0","561f72bacec1a50d00979598","561f764f61c0521700acc428","563337539c607719001b85dd","564318f1f49bfa0d002f5566","564f03454f000617007bd670","565ee80a23fd5f0d00a129f9","56793cd73473bc0d008e141b"],"project":"54aa7f773b56130b0056c86e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:43:51.897Z","from_sync":false,"order":3,"slug":"ios-sdk","title":"iOS SDK"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-14T12:20:15.928Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":18,"body":"Inbox Authorization allows you to block the inbox from unauthorized users until they succsesfully log in to your app and become authorised to view the inbox.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. User Authorization\"\n}\n[/block]\nWith the usage of the *setUserAuthorized(BOOL)* method you can easily inform the SDK if the given user is authorized or not. By default an user is always authorized.\n\nUnauthorized users will not be able to enter the inbox via a notification.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Please note that if you manually open the inbox using the *getFeedNavigationController* method the inbox will still open. You must write your own logic to block this.\",\n  \"title\": \"Manually opening the inbox\"\n}\n[/block]\nExample usage\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (IBAction)unauthorizeButtonClick:(id)sender {\\n    PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\\n    [manager setUserAuthorized:NO];\\n}\\n\\n- (IBAction)authorizeButtonClick:(id)sender {\\n    PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\\n    [manager setUserAuthorized:YES];\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. PULPulsateUnauthorizedManagerDelegate\"\n}\n[/block]\nPulsate allows you to get callbacks everytime an unauthorized action happens.\n\nUnauthorized user actions:\n1. Entering the app via a card notification\n2. Entering the app via a message notification \n\nExample Usage with Objective-C:\nIn your AppDelegate.h add the following code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \":::at:::interface AppDelegate : UIResponder <UIApplicationDelegate, PULPulsateUnauthorizedManagerDelegate>\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nIn your AppDelegate.m\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)unauthorizedAction:(NSString *)action {\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nAlso in your AppDelegate in the *didFinishLaunchingWithOptions* method add the following code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\\n    PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\\n    manager.unauthorizedDelegate = self;\\n    return YES;\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nNow every time an unauthorized user does any of the actions above the *unauthorizedAction* method will be called.\n\nExample usage in Swift:\nIn your AppDelegate.swift\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import UIKit\\nimport CoreData\\nimport PULPulsate\\n\\n@UIApplicationMain\\nclass AppDelegate: UIResponder, UIApplicationDelegate, PULPulsateUnauthorizedManagerDelegate {\\n\\t\\n  var window: UIWindow?\\n    \\n  func unauthorizedAction(_ action: String!) \\n  {\\n  }\\n    \\n  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool \\n  {\\n      do {\\n          let authData: PULAuthorizationData = try PULAuthorizationData(appId: \\\"APP_ID\\\", andAppKey: \\\"APP_KEY\\\")\\n            \\n          let pulsateManager = try PULPulsateFactory.getInstanceWith(authData, withLocationEnabled: true, withPushEnabled: true, withLaunchOptions: launchOptions)\\n          pulsateManager.unauthorizedDelegate = self;           \\n      } catch {\\n          print(error)\\n      }\\n\\n      return true\\n    }\\n}\\n\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Showing the last blocked unauthorized message\"\n}\n[/block]\nThis method allows you to show the last blocked unauthorized message.\n\nIf the user clicked a notification with a new card, but was unauthorized the user will not see that card. After setting *setUserAuthorized:YES* call *showLastUnauthorizedMessage* and we will redirect the user to the card that was blocked.\n\nIf the user clicked a notification with a new message, but was unauthorized the user will not see that message. After setting *setUserAuthorized:YES* call *showLastUnauthorizedMessage* and we will redirect the user to the message that was blocked.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (IBAction)authorizeButtonClick:(id)sender {\\n    PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\\n    [manager setUserAuthorized:YES];\\n    [manager showLastUnauthorizedMessage];\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. Enabling / Disabling In App Notifications\"\n}\n[/block]\nThe *enableInAppNotification* method allows you to enable or disable showing In App Notifications to the user.\n\nSometimes In App Notifications might contain info that you want only authorized users to see.\nIf you want to disable In App Notifications just simply call *enableInAppNotification:NO* to enable them call *enableInAppNotification:YES*.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\\n[manager enableInAppNotification:YES/NO];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"5. Showing Blocked In App Notifications\"\n}\n[/block]\nThe *showLastInAppNotification* method allows you to show the last In App Notification that came to the user.\n\nWhen an user has In App Notifications disabled the last In App Notification will be kept in the SDK allowing you to show it later. For example when an user is logged out you call *enableInAppNotification:NO* to disable In App Notifications, if the user receives an In App Notification it will be blocked. After calling *enableInAppNotification:YES* you can call *showLastInAppNotification* to show the user the last blocked In App Notification.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\\n[manager enableInAppNotification:YES];\\n[manager showLastInAppNotification];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"inbox-authorization","type":"basic","title":"User & Inbox Authorization - iOS"}

User & Inbox Authorization - iOS


Inbox Authorization allows you to block the inbox from unauthorized users until they succsesfully log in to your app and become authorised to view the inbox. [block:api-header] { "type": "basic", "title": "1. User Authorization" } [/block] With the usage of the *setUserAuthorized(BOOL)* method you can easily inform the SDK if the given user is authorized or not. By default an user is always authorized. Unauthorized users will not be able to enter the inbox via a notification. [block:callout] { "type": "warning", "body": "Please note that if you manually open the inbox using the *getFeedNavigationController* method the inbox will still open. You must write your own logic to block this.", "title": "Manually opening the inbox" } [/block] Example usage [block:code] { "codes": [ { "code": "- (IBAction)unauthorizeButtonClick:(id)sender {\n PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\n [manager setUserAuthorized:NO];\n}\n\n- (IBAction)authorizeButtonClick:(id)sender {\n PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\n [manager setUserAuthorized:YES];\n}", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "2. PULPulsateUnauthorizedManagerDelegate" } [/block] Pulsate allows you to get callbacks everytime an unauthorized action happens. Unauthorized user actions: 1. Entering the app via a card notification 2. Entering the app via a message notification Example Usage with Objective-C: In your AppDelegate.h add the following code [block:code] { "codes": [ { "code": "@interface AppDelegate : UIResponder <UIApplicationDelegate, PULPulsateUnauthorizedManagerDelegate>", "language": "objectivec" } ] } [/block] In your AppDelegate.m [block:code] { "codes": [ { "code": "- (void)unauthorizedAction:(NSString *)action {\n}", "language": "objectivec" } ] } [/block] Also in your AppDelegate in the *didFinishLaunchingWithOptions* method add the following code [block:code] { "codes": [ { "code": " (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\n manager.unauthorizedDelegate = self;\n return YES;\n}\n", "language": "objectivec" } ] } [/block] Now every time an unauthorized user does any of the actions above the *unauthorizedAction* method will be called. Example usage in Swift: In your AppDelegate.swift [block:code] { "codes": [ { "code": "import UIKit\nimport CoreData\nimport PULPulsate\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate, PULPulsateUnauthorizedManagerDelegate {\n\t\n var window: UIWindow?\n \n func unauthorizedAction(_ action: String!) \n {\n }\n \n func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool \n {\n do {\n let authData: PULAuthorizationData = try PULAuthorizationData(appId: \"APP_ID\", andAppKey: \"APP_KEY\")\n \n let pulsateManager = try PULPulsateFactory.getInstanceWith(authData, withLocationEnabled: true, withPushEnabled: true, withLaunchOptions: launchOptions)\n pulsateManager.unauthorizedDelegate = self; \n } catch {\n print(error)\n }\n\n return true\n }\n}\n", "language": "swift" } ] } [/block] [block:api-header] { "type": "basic", "title": "3. Showing the last blocked unauthorized message" } [/block] This method allows you to show the last blocked unauthorized message. If the user clicked a notification with a new card, but was unauthorized the user will not see that card. After setting *setUserAuthorized:YES* call *showLastUnauthorizedMessage* and we will redirect the user to the card that was blocked. If the user clicked a notification with a new message, but was unauthorized the user will not see that message. After setting *setUserAuthorized:YES* call *showLastUnauthorizedMessage* and we will redirect the user to the message that was blocked. [block:code] { "codes": [ { "code": "- (IBAction)authorizeButtonClick:(id)sender {\n PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\n [manager setUserAuthorized:YES];\n [manager showLastUnauthorizedMessage];\n}", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. Enabling / Disabling In App Notifications" } [/block] The *enableInAppNotification* method allows you to enable or disable showing In App Notifications to the user. Sometimes In App Notifications might contain info that you want only authorized users to see. If you want to disable In App Notifications just simply call *enableInAppNotification:NO* to enable them call *enableInAppNotification:YES*. [block:code] { "codes": [ { "code": "PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\n[manager enableInAppNotification:YES/NO];", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "5. Showing Blocked In App Notifications" } [/block] The *showLastInAppNotification* method allows you to show the last In App Notification that came to the user. When an user has In App Notifications disabled the last In App Notification will be kept in the SDK allowing you to show it later. For example when an user is logged out you call *enableInAppNotification:NO* to disable In App Notifications, if the user receives an In App Notification it will be blocked. After calling *enableInAppNotification:YES* you can call *showLastInAppNotification* to show the user the last blocked In App Notification. [block:code] { "codes": [ { "code": "PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\n[manager enableInAppNotification:YES];\n[manager showLastInAppNotification];", "language": "objectivec" } ] } [/block]