User & Attributes
Managing User Data
The NetmeraUser
class allows you to send structured information about your application's users to Netmera. The ideal time to update user attributes is right after the user logs into your application.
User ID Management
For optimal performance and data integrity:
Update user information at login: It’s crucial to update the user information as soon as the user logs in.
Unique userId: Ensure that each user has a unique
userId
. Assigning the sameuserId
to multiple users leads to data inconsistencies and is not recommended.
Updating User Information
After obtaining user information, set or update the user data by using the following example. You can update any attribute independent from the others.
Removing Attributes
To remove a previously set attribute, assign [NSNull null]
to the attribute in the user object.
UserId cannot be removed:
userId
cannot be removed, even if set to null
.
Creating Custom Profile Attributes
Step 1: Navigate to the Developers section
Custom profile attributes must be created and configured in the Netmera Panel before they can be used in the application.
Go to Panel > Developers > Profile Attributes > Create New Attribute.
Step 2: Fill in Attribute Details
Define the following information:
Name: The unique identifier for the attribute.
Label: A user-friendly name for the attribute.
Description: A brief description of the attribute.
Data Type: Choose the appropriate data type for the attribute.
Is Array: Define whether the attribute can hold multiple values.
Step 3: Save the Attribute
After clicking Save, the custom attribute will be available for assignment to your users.
Step 4: Generated Code for Custom Attributes
Once the attribute is defined in the Netmera Panel, the generated code can be found at the bottom of the Profile Attribute page, under the Generate Code section. This code must be added to your Netmera Panel under Profile Attributes > User Class.
Private Information Considerations
Under the KVKK law, the sharing of private user data is prohibited. To ensure compliance:
Private Information Flag: When defining profile attributes or events, the Private Information feature must be selected to ensure that these attributes are not sent to the backend by the Netmera SDK.
SDK Enforcement: The SDK checks for the Private Information flag during the
Netmera.updateUser(user:)
call. If the flag is set, the request will not be sent to the backend.

fetchCoupon
The fetchCoupon
method in Netmera allows you to retrieve and display the coupons earned by users in your iOS application. You can use the NetmeraCouponFilter
to define the filtering criteria, such as the page number and the maximum number of coupons to retrieve.
Create a Filter: Use
NetmeraCouponFilter
to set the page number and the maximum number of coupons to retrieve.Call the
fetchCoupon
Method: Pass the filter to thefetchCoupon
method to fetch the coupons.Handle the Result: Inside the closure, check if the coupons are fetched successfully. If so, assign them to the
coupons
property and reload the table view to display them.
User Update
The User Update
feature calls the update
function from the Netmera SDK, passing a user
object as a parameter to update the user data. The function uses a closure (callback) to handle the result of the update. Depending on the success or failure of the update, a corresponding block is triggered.
Successful Update: If the update is successful, the success block is triggered, and "success" is printed to the console.
Error in Update: If an error occurs during the update, the error block is triggered, and "error" is printed.
Last updated
Was this helpful?