Grial License Setup
Grial requires a license file in order to execute. Once you purchase the product you will be redirected to the Grial Web Admin website where you can register your app and download its license.
- The license is a file (named
GrialLicense
by default), that must be added at the root of your platform specific projects (iOS and Android). - The file must have Build Action
Embedded Resource
. - The kit must be initialized by calling method
UXDivers.Grial.GrialKit.Init()
before using any Grial component, passing the name of the embedded resource that contains the license. Otherwise it will fail.
In Xamarin.Forms, an embedded resource name is formed by the following scheme:
<Default Namespace of the Container Project>.<Name of the File>
.
So, assuming the default namespace of your Android Project is MyApp.Droid
and the license file is called GrialLicense
you will call Init
passing the name MyApp.Droid.GrialLicense
iOS is analogous, but taking the default namespace of the iOS project.
Android Setup
namespace MyApp.Droid
{
...
public class MainActivity : FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
...
GrialKit.Init(this, "MyApp.Droid.GrialLicense");
...
iOS Setup
namespace MyApp.iOS
{
public class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
...
GrialKit.Init(new ThemeColors(), "MyApp.iOS.GrialLicense");
...
The Init
method will verify that:
- Android your app name and package name match those defined in the license.
- iOS your app name and bundle identifier match those defined in the license.
tip
Important: if your Application is localized the license check also verifies the localized names you define in Grial Web Admin.
If any of those does not match, the license verification will say which one fails. See License Verification for a detailed explanation.
License modes
The licenses you download from Grial Web Admin website have two modes:
Development Mode (default)
- This is meant while things are being developed and may change.
- Expires 30 days after the generation date. In such case, it displays an error with a link to renew and download a new one.
- Can be renewed anytime to get another 30.
Production Mode
- You should switch to this mode once you are ready to publish the app and you are sure about the final name, android package and iOS bundle identifier of your app.
- Production licenses never expire.
- Once in this mode there is no way to change it back to development mode and you will no longer be able to edit your app info in the Grial Web Admin website.
License Verification
In Android, the license verification will check that:
- the license's app name matches your app name as defined in the
AndroidManifest.xml
andMainActivity.cs
. Note that the name may depend upon the culture if you have a localized app - the license's package name matches your app's package name as defined in the
AndroidManifest.xml
.
The following code fragments illustrates which values should match:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ... package="ANDROID_PACKAGE_NAME" ...>
...
<application ... android:label="@string/app_name" ...></application>
...
</manifest>
MainActivity.cs
namespace MyApp.Droid
{
[Activity(Label = @string/app_name, ...)]
public class MainActivity : FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
...
Application name is declared through @string/app_name
. This is a localized Android string that defines the application name. The actual
value of the string is defined in the Strings.xml
resource file:
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<string name="app_name">My App Name</string>
</resources>
If you define multiple cultures in Grial Web Admin you will see multiple value-CULTURE
folders (in the image above -ar
stands for Arabic), each with the specific name you pick.
If the app is not localized, only one Strings file under values
folder will exist and will be the one containing the name.
In case the Application is localized, the check will verify that the runtime name matches the one defined in the license for the current culture.
In iOS, the license verification will check that:
- the license's app name matches the name defined in the
Info.plist
file.- If the
CFBundleDisplayName
is defined it will be considered as the application's name. - If it is not defined, the
CFBundleName
will be used. - Note that the name may depend upon the culture if you have a localized app.
- If the
- the license's bundle identifier matches the
CFBundleIdentifier
entry in theInfo.plist
.
In case you have a localized app defined in Grial Web Admin, you will see multiple Info.plist
alternative files:
Each file defines CFBundleDisplayName
and CFBundleName
for the specific culture defined by the folder name. In the image
above en
stands for English and ar
for Arabic.
In case the Application is localized, the check will verify that the runtime display name (or name when display name is not defined) matches the one defined in the license for the current culture.