{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]},"settings":""},"next":{"description":"","pages":[]},"title":"User & Inbox Authorization - Android","type":"basic","slug":"user-inbox-authorization-android","excerpt":"","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]","updates":[],"order":0,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5f2ab2f8ddc6e8045af2bb85","createdAt":"2020-08-05T13:24:08.561Z","user":"57bc3654b9c7f0220009c77b","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"SDK Advanced","slug":"sdk-advanced","order":3,"from_sync":false,"reference":false,"_id":"5f2ab1f9c1644603559149ac","createdAt":"2020-08-05T13:19:53.807Z","version":"5e5019b49e8f240011cc6ade","project":"54aa7f773b56130b0056c86e","__v":0},"version":{"version":"2.8","version_clean":"2.8.0","codename":"Android SDK","is_stable":false,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5e5019b49e8f240011cc6a47","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","5e5019b49e8f240011cc6a48","5e5019b49e8f240011cc6a49","5e5019b49e8f240011cc6a4a","5e5019b49e8f240011cc6a4b","5e5019b49e8f240011cc6a4c","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","5e5019b49e8f240011cc6a4d","5e5019b49e8f240011cc6a4e","5c73dd27e8fdc000572a206a","5e5019b49e8f240011cc6a4f","5e501b7e7c8bdc00450ea66a","5e53daa9884b750025b5cad4","5f2ab0dfbf70f7063ad0c4f3","5f2ab1e9448d87068b348f9c","5f2ab1f9c1644603559149ac","5f2ab205bc35e507e8cead35"],"_id":"5e5019b49e8f240011cc6ade","project":"54aa7f773b56130b0056c86e","forked_from":"5e4fbbbda8fb41028f1861fe","__v":6,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z"},"project":"54aa7f773b56130b0056c86e","__v":0,"parentDoc":null}

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]