{"_id":"57878a83c18e7a0e00bf516f","project":"54aa7f773b56130b0056c86e","user":"54aa7f3f9bb00c0b00cb899b","githubsync":"","parentDoc":null,"__v":5,"category":{"_id":"55781fe35129590d003ff4fc","pages":["55781fe45129590d003ff50d","55781fe45129590d003ff50e","55781fe45129590d003ff50f","55781fe45129590d003ff510","55781fe45129590d003ff511","55781fe45129590d003ff512","55781fe45129590d003ff513","55781fe45129590d003ff514","55781fe45129590d003ff515","55781fe45129590d003ff516","55f692b4fe4cce21005c78b0","55f7e91e60cc850d008a7a45","56333cab9c607719001b85e4","564462ed9ce94c0d00068ce9","564f54fa48a1df1700836653","565ee9e7413e06170093dde0","5661a8fdb401c70d00dde6fa","5671348860c8e70d006c96a1","568ce9707d3bf02300aa7734"],"version":"55781fe25129590d003ff4f7","__v":10,"project":"54aa7f773b56130b0056c86e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:44:00.338Z","from_sync":false,"order":4,"slug":"android-sdk","title":"Android SDK"},"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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-14T12:50:11.968Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":21,"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(boolean)* 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 in any way.\n\nExample usage\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"authorizeButton.setOnClickListener(new View.OnClickListener() {\\n    :::at:::Override\\n    public void onClick(View v) {\\n        pulsateManager.setUserAuthorized(true);\\n    }\\n});\\n\\nunauthorizeButton.setOnClickListener(new View.OnClickListener() {\\n    @Override\\n    public void onClick(View v) {\\n        pulsateManager.setUserAuthorized(false);\\n    }\\n});\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Listening to unauthorized actions\"\n}\n[/block]\nWith the usage of the *setUserUnauthorizedListener* method you can easily set an *IPulsateUserUnauthorizedListener* which will inform you whenever an unauthorized action happens.\n\nUnauthorized action - trying to start the inbox in any way (via notification / in app message / showFeed method).\n\nExample usage:\nIn your Application Class add the following code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@Override\\npublic void onCreate() {\\n    IPulsateManager manager = PulsateFactory.getInstance();\\n    manager.setUserUnauthorizedListener(new IPulsateUserUnauthorizedListener() {\\n        @Override\\n        public void onUnauthorizedAction() {\\n            //Your code goes here\\n        }\\n    });\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nNow every time an unauthorized user tries to enter the inbox the *IPulsateUserUnauthorizedListener* will receive a callback.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Showing Unauthorized messages\"\n}\n[/block]\nThe *showLastUnauthorizedMessage* method allows you to show the last blocked inbox intent.\n\nIf the user clicked a notification with a new card, but was unauthorized the user will not see that card. After setting *setUserAuthorized(true)* 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(true)* call *showLastUnauthorizedMessage* and we will redirect the user to the message that was blocked.\n\nIf the user tried to enter the inbox manually, but was unauthorized the inbox will not open. After setting *setUserAuthorized(true)* call *showLastUnauthorizedMessage* and we will redirect the user to the inbox.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"authorizeButton.setOnClickListener(new View.OnClickListener() {\\n    @Override\\n    public void onClick(View v) {\\n        pulsateManager.setUserAuthorized(true);\\n        pulsateManager.showLastUnauthorizedMessage();\\n    }\\n});\",\n      \"language\": \"java\"\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 *setInAppNotificationEnabled* 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 *setInAppNotificationEnabled(false)* to enable them call *setInAppNotificationEnabled(true)*.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" pulsateManager.setInAppNotificationEnabled(true/false);\",\n      \"language\": \"java\"\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 to him. For example when an user is logged out you call *setInAppNotificationEnabled(false)* to disable In App Notifications, if the user receives an In App Notification it will be blocked. After calling *setInAppNotificationEnabled(true)* you can call *showLastInAppNotification()* to show the user the last blocked In App Notification.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pulsateManager.setInAppNotificationEnabled(true);\\npulsateManager.showLastInAppNotification();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"inbox-authorization-android","type":"basic","title":"User & Inbox Authorization - Android"}

User & Inbox Authorization - Android


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(boolean)* 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 in any way. Example usage [block:code] { "codes": [ { "code": "authorizeButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n pulsateManager.setUserAuthorized(true);\n }\n});\n\nunauthorizeButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n pulsateManager.setUserAuthorized(false);\n }\n});", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "2. Listening to unauthorized actions" } [/block] With the usage of the *setUserUnauthorizedListener* method you can easily set an *IPulsateUserUnauthorizedListener* which will inform you whenever an unauthorized action happens. Unauthorized action - trying to start the inbox in any way (via notification / in app message / showFeed method). Example usage: In your Application Class add the following code [block:code] { "codes": [ { "code": "@Override\npublic void onCreate() {\n IPulsateManager manager = PulsateFactory.getInstance();\n manager.setUserUnauthorizedListener(new IPulsateUserUnauthorizedListener() {\n @Override\n public void onUnauthorizedAction() {\n //Your code goes here\n }\n });\n}", "language": "java" } ] } [/block] Now every time an unauthorized user tries to enter the inbox the *IPulsateUserUnauthorizedListener* will receive a callback. [block:api-header] { "type": "basic", "title": "3. Showing Unauthorized messages" } [/block] The *showLastUnauthorizedMessage* method allows you to show the last blocked inbox intent. If the user clicked a notification with a new card, but was unauthorized the user will not see that card. After setting *setUserAuthorized(true)* 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(true)* call *showLastUnauthorizedMessage* and we will redirect the user to the message that was blocked. If the user tried to enter the inbox manually, but was unauthorized the inbox will not open. After setting *setUserAuthorized(true)* call *showLastUnauthorizedMessage* and we will redirect the user to the inbox. [block:code] { "codes": [ { "code": "authorizeButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n pulsateManager.setUserAuthorized(true);\n pulsateManager.showLastUnauthorizedMessage();\n }\n});", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. Enabling / Disabling In App Notifications" } [/block] The *setInAppNotificationEnabled* 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 *setInAppNotificationEnabled(false)* to enable them call *setInAppNotificationEnabled(true)*. [block:code] { "codes": [ { "code": " pulsateManager.setInAppNotificationEnabled(true/false);", "language": "java" } ] } [/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 to him. For example when an user is logged out you call *setInAppNotificationEnabled(false)* to disable In App Notifications, if the user receives an In App Notification it will be blocked. After calling *setInAppNotificationEnabled(true)* you can call *showLastInAppNotification()* to show the user the last blocked In App Notification. [block:code] { "codes": [ { "code": "pulsateManager.setInAppNotificationEnabled(true);\npulsateManager.showLastInAppNotification();", "language": "java" } ] } [/block]