User Portrait Screenlet for iOS

Requirements

  • Xcode 9.3 or above
  • iOS 11 SDK
  • Liferay Portal 6.2 CE/EE, Liferay CE Portal 7.0/7.1, Liferay DXP

Compatibility

  • iOS 9 and above

Xamarin Requirements

  • Visual Studio 7.2
  • Mono .NET framework 5.4.1.6

Features

The User Portrait Screenlet shows the user’s portrait from Liferay Portal. If the user doesn’t have a portrait configured, a placeholder image is shown.

JSON Services Used

Screenlets in Liferay Screens call JSON web services in the portal. This Screenlet calls the following services and methods.

ServiceMethodNotes
UserServicegetUserById
UserServicegetUserByEmailAddress
UserServicegetUserByScreenName

Module

  • None

Themes

  • Default (default)
  • Flat7 (flat7)

The User Portrait Screenlet using the Default and Flat7 Themes.

Portal Configuration

None

Offline

This Screenlet supports offline mode so it can function without a network connection. For more information on how offline mode works, see the tutorial on its architecture.

When loading the portrait, the Screenlet supports the following offline mode policies:

PolicyWhat happensWhen to use
remote-onlyThe Screenlet loads the user portrait from the portal. If a connection issue occurs, the Screenlet uses the delegate to notify the developer about the error. If the Screenlet loads the portrait, it stores the received image in the local cache for later use.Use this policy when you always need to show updated portraits, and show the default placeholder when there’s no connection.
cache-onlyThe Screenlet loads the user portrait from the local cache. If the portrait isn’t there, the Screenlet uses the delegate to notify the developer about the error.Use this policy to show local portraits, without retrieving remote information under any circumstance.
remote-firstThe Screenlet loads the user portrait from the portal. The Screenlet displays the portrait to the user and stores it in the local cache for later use. If a connection issue occurs, the Screenlet retrieves the portrait from the local cache. If the portrait doesn’t exist there, the Screenlet uses the delegate to notify the developer about the error.Use this policy to show the most recent portrait when connected, but show a potentially outdated version when there’s no connection.
cache-firstIf the portrait exists in the local cache, the Screenlet loads it from there. If it doesn’t exist there, the Screenlet requests the portrait from the portal and uses the delegate to notify the developer about any connection errors.Use this policy to save bandwidth and loading time in the event a local (but probably outdated) portrait exists.

When editing the portrait, the Screenlet supports the following offline mode policies:

PolicyWhat happensWhen to use
remote-onlyThe Screenlet sends the user portrait to the portal. If a connection issue occurs, the Screenlet uses the delegate to notify the developer about the error, but it also discards the new portrait.Use this policy when you need to make sure portal always has the most recent version of the portrait.
cache-onlyThe Screenlet stores the user portrait in the local cache.Use this policy when you need to save the portrait locally, but don’t want to change the portrait in the portal.
remote-firstThe Screenlet sends the user portrait to the portal. If this succeeds, the Screenlet also stores the portrait in the local cache for later usage. If a connection issue occurs, the Screenlet stores the portrait in the local cache with the dirty flag enabled. This causes the portrait to be sent to the portal when the synchronization process runs.Use this policy when you need to make sure the Screenlet sends the new portrait to the portal as soon as the connection is restored.
cache-firstThe Screenlet stores the user portrait in the local cache and then sends it to the portal. If a connection issue occurs, the Screenlet stores the portrait in the local cache with the dirty flag enabled. This causes the portrait to be sent to the portal when the synchronization process runs.Use this policy when you need to make sure the Screenlet sends the new portrait to the portal as soon as the connection is restored. Compared to remote-first, this policy always stores the portrait in the cache. The remote-first policy only stores the new image in the event of a network error.

Attributes

AttributeData typeExplanation
borderWidthnumberThe size in pixels for the portrait’s border. The default value is 1. Set this to 0 if you want to hide the border.
borderColorUIColorThe border’s color. Use the system’s transparent color to hide the border.
editablebooleanLets the user change the portrait image by taking a photo or selecting a gallery picture. The default value is false. Portraits loaded with the load(portraitId, uuid, male) method aren’t editable.
offlinePolicystringConfigure the loading and saving behavior in case of connectivity issues. For more details, read the “Offline” section below.

Methods

MethodReturnExplanation
loadLoggedUserPortrait()booleanStarts the request to load the currently logged in user’s portrait image (see the SessionContext class).
load(userId)booleanStarts the request to load the specified user’s portrait image.
load(portraitId, uuid, male)booleanStarts the request to load the portrait image using the specified user’s data. The parameters portraitId and uuid can be retrieved by using the SessionContext.userAttributes() method.
load(companyId, emailAddress)booleanStarts the request to load the portrait image using the user’s email address.
load(companyId, screenName)booleanStarts the request to load the portrait image using the user’s screen name.

Delegate

The User Portrait Screenlet delegates some events to an object that conforms to the UserPortraitScreenletDelegate protocol. This protocol lets you implement the following methods:

  • - screenlet:onUserPortraitResponseImage:: Called when an image is received from the server. You can then apply image filters (grayscale, for example) and return the new image. You can return the original image supplied as the argument if you don’t want to modify it.

  • - screenlet:onUserPortraitError:: Called when an error occurs in the process. The NSError object describes the error.

  • - screenlet:onUserPortraitUploaded:: Called when a new portrait is uploaded to the server. You receive the user attributes as a parameter.

  • - screenlet:onUserPortraitUploadError:: Called when an error occurs in the upload process. The NSError object describes the error.

« Forgot Password Screenlet for iOSDDL Form Screenlet for iOS »
Was this article helpful?
0 out of 0 found this helpful