Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Push notification with Azure notification Hub is working in debug mode but not in release

$
0
0

My App is running on Xamarin.Forms 4.7 for android only and I have followed the instruction given on Microsoft site My App is running on Xamarin.Forms 4.7 for android only and I have followed the instruction given on Microsoft site and push notification work in debug mode on emulator but if I release app and install on real device or emulator, it doesn't work.

Below is my Androidmenifiest:
























    <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/Support_Desk_Logo" />

    <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id" />

    <service android:exported="true" android:name="com.bientechnologies.MyFirebaseMessagingService" android:stopWithTask="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>
    <uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>

Below, is my class which intercepts the notifications:

```[Service(Enabled = true, Exported = true, Name = "com.bientechnologies.MyFirebaseMessagingService")]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
[IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
public class MyFirebaseMessagingService : FirebaseMessagingService
{
public static System.String MyToken = "";
const string TAG = "MyFirebaseMsgService";

public override void OnNewToken(string token)
{
    // NOTE: save token instance locally, or log if desired

    try
    {
        SendRegistrationToServer(token, this);
        if (App.IsUserLoggedIn)
        {
            Task.Run(async () =>
            {

                var service = new Bien.DeskApp.Services.NotificationService();
                await service.SubscribeAsync(App.LoginResponse.Username, token);
            });
        }
    }
    catch (Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}

public static void SendRegistrationToServer(string token, Context context)
{
    try
    {
        NotificationHub hub = new NotificationHub(Constants.NotificationHubName, Constants.ListenConnectionString, context);

        // register device with Azure Notification Hub using the token from FCM
        Registration registration = hub.Register(token, Constants.SubscriptionTags);

        // subscribe to the SubscriptionTags list with a simple template.
        string pnsHandle = registration.PNSHandle;
        TemplateRegistration templateReg = hub.RegisterTemplate(pnsHandle, "defaultTemplate", Constants.FCMTemplateBody, Constants.SubscriptionTags);
    }
    catch (Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering device: {e.Message}");
    }
}

public override void OnMessageReceived(RemoteMessage message)
{

    try
    {
        Log.Debug(TAG, "From: " + message.From);
        if (message.GetNotification() != null)
        {
            //These is how most messages will be received
            Log.Debug(TAG, "Notification Message Body: " + message.GetNotification().Body);
            SendNotification(message.GetNotification().Body);
        }
        else if (message.Data.Values.Any())
        {
            //Only used for debugging payloads sent from the Azure portal
            SendNotification(message.Data.Values.First());
        }
    }
    catch(Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}

void SendNotification(string messageBody)
{
    try
    {
        var intent = new Intent(this, typeof(MainActivity));
        intent.AddFlags(ActivityFlags.ClearTop);
        var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
        string channelNameAndroid = "Android Channel";

        NotificationChannel androidChannel = new NotificationChannel(Constants.CHANNEL_ID, channelNameAndroid, NotificationImportance.Default);
        androidChannel.EnableVibration(true);
        androidChannel.SetSound(null, null);
        androidChannel.ShouldShowLights();
        androidChannel.EnableLights(true);
        androidChannel.SetShowBadge(true);
        androidChannel.LightColor = Resource.Color.accent_material_light;
        androidChannel.LockscreenVisibility = NotificationVisibility.Public;

        var notificationManager = (NotificationManager)GetSystemService(Android.Content.Context.NotificationService);
        if (notificationManager == null)
        {
            notificationManager = NotificationManager.FromContext(this);
        }

        notificationManager.CreateNotificationChannel(androidChannel);

        var notificationBuilder = new NotificationCompat.Builder(this, Constants.CHANNEL_ID);

        notificationBuilder.SetContentTitle("Bien Desk")
                    .SetSmallIcon(Resource.Drawable.smallicon)
                    .SetLargeIcon(Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.Support_Desk_Logo))
                    .SetContentText(messageBody)
                    .SetAutoCancel(false)
                    .SetShowWhen(true)
                    .SetGroup("biendesk")
                    .SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate)
                    .SetContentIntent(pendingIntent);

        // var notificationManager = NotificationManager.FromContext(this);
        notificationManager.Notify(new Random().Next(), notificationBuilder.Build());
    }
    catch(Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}

private void MountAlert(string title, string message, PendingIntent intent)
{
    try
    {
        string channelIdAndroid = Constants.CHANNEL_ID;
        string channelNameAndroid = "Android Channel";

        if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
        {
            NotificationChannel androidChannel = new NotificationChannel(channelIdAndroid, channelNameAndroid, NotificationImportance.Default);
            androidChannel.EnableVibration(true);
            androidChannel.SetSound(null, null);
            androidChannel.ShouldShowLights();
            androidChannel.EnableLights(true);
            androidChannel.SetShowBadge(true);
            androidChannel.LightColor = Resource.Color.accent_material_light;
            androidChannel.LockscreenVisibility = NotificationVisibility.Public;

            var notificationManager = (NotificationManager)GetSystemService(Android.Content.Context.NotificationService);

            notificationManager.CreateNotificationChannel(androidChannel);

            var notificationBuilder = new Notification.Builder(this, channelIdAndroid)
                            .SetSmallIcon(Resource.Drawable.smallicon)
                            .SetLargeIcon(Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.Support_Desk_Logo))
                            .SetColor(Resource.Color.accent_material_light)
                            .SetContentTitle(title)
                            .SetContentText(message)
                            .SetAutoCancel(true)
                            .SetStyle(new Notification.BigTextStyle().BigText(message))
                            .SetContentIntent(intent);

            notificationManager.Notify(new Random().Next(), notificationBuilder.Build());
        }
    }
    catch (Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}```

Please suggest what I am missing.

thanks and push notification work in debug mode on emulator but if I release app and install on real device or emulator, it doesn't work.

Below is my Androidmenifiest:

```






















    <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/Support_Desk_Logo" />

    <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id" />

    <service android:exported="true" android:name="com.bientechnologies.MyFirebaseMessagingService" android:stopWithTask="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>
    <uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>

```

Below, is my class which intercepts the notifications:

```[Service(Enabled = true, Exported = true, Name = "com.bientechnologies.MyFirebaseMessagingService")]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
[IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
public class MyFirebaseMessagingService : FirebaseMessagingService
{
public static System.String MyToken = "";
const string TAG = "MyFirebaseMsgService";

public override void OnNewToken(string token)
{
    // NOTE: save token instance locally, or log if desired

    try
    {
        SendRegistrationToServer(token, this);
        if (App.IsUserLoggedIn)
        {
            Task.Run(async () =>
            {

                var service = new Bien.DeskApp.Services.NotificationService();
                await service.SubscribeAsync(App.LoginResponse.Username, token);
            });
        }
    }
    catch (Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}

public static void SendRegistrationToServer(string token, Context context)
{
    try
    {
        NotificationHub hub = new NotificationHub(Constants.NotificationHubName, Constants.ListenConnectionString, context);

        // register device with Azure Notification Hub using the token from FCM
        Registration registration = hub.Register(token, Constants.SubscriptionTags);

        // subscribe to the SubscriptionTags list with a simple template.
        string pnsHandle = registration.PNSHandle;
        TemplateRegistration templateReg = hub.RegisterTemplate(pnsHandle, "defaultTemplate", Constants.FCMTemplateBody, Constants.SubscriptionTags);
    }
    catch (Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering device: {e.Message}");
    }
}

public override void OnMessageReceived(RemoteMessage message)
{

    try
    {
        Log.Debug(TAG, "From: " + message.From);
        if (message.GetNotification() != null)
        {
            //These is how most messages will be received
            Log.Debug(TAG, "Notification Message Body: " + message.GetNotification().Body);
            SendNotification(message.GetNotification().Body);
        }
        else if (message.Data.Values.Any())
        {
            //Only used for debugging payloads sent from the Azure portal
            SendNotification(message.Data.Values.First());
        }
    }
    catch(Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}

void SendNotification(string messageBody)
{
    try
    {
        var intent = new Intent(this, typeof(MainActivity));
        intent.AddFlags(ActivityFlags.ClearTop);
        var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
        string channelNameAndroid = "Android Channel";

        NotificationChannel androidChannel = new NotificationChannel(Constants.CHANNEL_ID, channelNameAndroid, NotificationImportance.Default);
        androidChannel.EnableVibration(true);
        androidChannel.SetSound(null, null);
        androidChannel.ShouldShowLights();
        androidChannel.EnableLights(true);
        androidChannel.SetShowBadge(true);
        androidChannel.LightColor = Resource.Color.accent_material_light;
        androidChannel.LockscreenVisibility = NotificationVisibility.Public;

        var notificationManager = (NotificationManager)GetSystemService(Android.Content.Context.NotificationService);
        if (notificationManager == null)
        {
            notificationManager = NotificationManager.FromContext(this);
        }

        notificationManager.CreateNotificationChannel(androidChannel);

        var notificationBuilder = new NotificationCompat.Builder(this, Constants.CHANNEL_ID);

        notificationBuilder.SetContentTitle("Bien Desk")
                    .SetSmallIcon(Resource.Drawable.smallicon)
                    .SetLargeIcon(Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.Support_Desk_Logo))
                    .SetContentText(messageBody)
                    .SetAutoCancel(false)
                    .SetShowWhen(true)
                    .SetGroup("biendesk")
                    .SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate)
                    .SetContentIntent(pendingIntent);

        // var notificationManager = NotificationManager.FromContext(this);
        notificationManager.Notify(new Random().Next(), notificationBuilder.Build());
    }
    catch(Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}

private void MountAlert(string title, string message, PendingIntent intent)
{
    try
    {
        string channelIdAndroid = Constants.CHANNEL_ID;
        string channelNameAndroid = "Android Channel";

        if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
        {
            NotificationChannel androidChannel = new NotificationChannel(channelIdAndroid, channelNameAndroid, NotificationImportance.Default);
            androidChannel.EnableVibration(true);
            androidChannel.SetSound(null, null);
            androidChannel.ShouldShowLights();
            androidChannel.EnableLights(true);
            androidChannel.SetShowBadge(true);
            androidChannel.LightColor = Resource.Color.accent_material_light;
            androidChannel.LockscreenVisibility = NotificationVisibility.Public;

            var notificationManager = (NotificationManager)GetSystemService(Android.Content.Context.NotificationService);

            notificationManager.CreateNotificationChannel(androidChannel);

            var notificationBuilder = new Notification.Builder(this, channelIdAndroid)
                            .SetSmallIcon(Resource.Drawable.smallicon)
                            .SetLargeIcon(Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.Support_Desk_Logo))
                            .SetColor(Resource.Color.accent_material_light)
                            .SetContentTitle(title)
                            .SetContentText(message)
                            .SetAutoCancel(true)
                            .SetStyle(new Notification.BigTextStyle().BigText(message))
                            .SetContentIntent(intent);

            notificationManager.Notify(new Random().Next(), notificationBuilder.Build());
        }
    }
    catch (Exception e)
    {
        Log.Error(Constants.DebugTag, $"Error registering token: {e.Message}");
    }
}```

Please suggest what I am missing.

thanks


PostAsync has occurred “the request timed out” on iOS Xamarin Forms

$
0
0

I use xamarin forms to create an mobile app for Android and iOS. I need to make Http Request, so I use HttpClient.

Here is a simple code of request :

var client = new HttpClient();
try
{
   string requestUrl = URL_DATABASE + "xxx";

   var content = new StringContent("{\"param\":\"" + param+ "\"}", Encoding.UTF8, "application/json");
   var response = await client.PostAsync(requestUrl, content);

   if (response.StatusCode == HttpStatusCode.OK)
   {
      var result = await response.Content.ReadAsStringAsync();
      return result;
   }

   return "{\"status\":-1}";
}

catch (Exception ex) // Error catched : "the request timed out"
{
   return "{\"status\":-1}";
}

I used Postman to check result of my request and work's well, I got good response without timeout.
I noticed that error occurs sometimes but can last an hour.

Thank you in advance for your help

Securely store sensitive data

$
0
0

How to securely store sensitive data such as Auth token upon login in Xamarin.Android app so that once stored, it can be accessed app-wide?
Thanks.

CollectionView bug

$
0
0

Hi guys! Im using Xamarin.Forms 4.7 in my project and have issue with CollectionView.
This bug appears only on iOS and is displayed in approximately one build out of 10. I guess that bottom tabbed page causes this issue. Is there any ways to fix this?

I updated to 4.6 and now iOS does not apply styles, colors and fonts to labels.

$
0
0

After updating to 4.6 my labels don't work properly in iOS.

If I have a label with Style="{StaticResource Blue1_Font16_Book}" and Text="{helpers:StringResource lblTimeCardSummaryGuideHint}" the style is not applied. It also does not work if the text is hardcoded. (StringResource is a markup extension that returns the value for the key passed to it.)

However, if the label is changed as follows: Style="{StaticResource Blue1_Font16_Book}" Text="{Binding lblTimeCardSummaryGuideHint}" />" the style is applied.

its taking time to load the image

$
0
0

this is my code

 private async void LoadStusentOrStaffPhoto()
    {
        try
        {
            int initalCount = 0;
            string studentsIDS = "";
            for (int i = 0; i < searchResults.Count; i++)
            {
                studentsIDS += searchResults[i].Id.ToString();
                initalCount++;
                if (initalCount > 9)
                {

                    GetStudentOrStaffPhoto(type, studentsIDS);
                    initalCount = 0;
                    studentsIDS = "";

                }
                else
                    studentsIDS += ",";
            }
        }
        catch (Exception ex)
        {
            CommonHelper.LogException(ex, this);
        }

    }


    async Task GetStudentOrStaffPhoto(string type, string studentStaffId)
    {
        try
        {
            if (Reachability.IsInternetReachable())
            {
                // Create Singleton instance of the account factory class
                SearchFactory searchFactory = SearchFactory.GetInstance;
                // Create appropriate account facade instance 
                var searchFacade = searchFactory.CreateSearchInstance(Entity.Common.SearchTypeEnum.RegularSearch);
                var schlCode = NSUserDefaults.StandardUserDefaults.StringForKey(AppConstants.LastSelSchoolCodeUDKey);

                var studentStaffPhotoResponse = await searchFacade.GetStudentOrStaffPhoto(schlCode, type, studentStaffId);
                if (studentStaffPhotoResponse.IsResponseSuccess)
                {
                    foreach (var item in studentStaffPhotoResponse.Response)
                    {
                        if (item.Image != null)
                        {
                            byte[] sPhoto = Convert.FromBase64String(item.Image);
                            var studentItem = searchResults.FindIndex(x => x.Id == item.Id);
                            if (studentItem != 0)
                            {
                                searchResults[studentItem].Photo = sPhoto;
                            }
                        }
                    }
                }
                else if (studentStaffPhotoResponse.IsUnauthorized)
                {
                    InvokeOnMainThread(() =>
                    {
                        CommonHelper.ShowUnauthorizedAlert(this);
                    });
                }
                else
                {
                    InvokeOnMainThread(() =>
                    {
                        var alert = UIAlertController.Create(NSBundle.MainBundle.GetLocalizedString(AppConstants.NoInternetTitleLKey, ""),
                                            NSBundle.MainBundle.GetLocalizedString(AppConstants.NoInternetMsgLKey, ""),
                                                    UIAlertControllerStyle.Alert);
                        alert.AddAction(UIAlertAction.Create(NSBundle.MainBundle.GetLocalizedString(AppConstants.OKLKey, ""),
                                         UIAlertActionStyle.Cancel, (obj) =>
                                         {
                                             NavigationController.PopViewController(true);
                                         }));
                        PresentViewController(alert, true, null);
                    });
                }
            }

            SearchResultTableView.TableHeaderView = GetTableHeader();
            SearchResultTableView.DataSource = this;
            SearchResultTableView.Delegate = this;
            SearchResultTableView.ReloadData();
            SearchResultTableView.BackgroundView = null;
        }
        catch (Exception ex)
        {
            CommonHelper.LogException(ex, this);
        }
    }

iOS App crashing when binding to Text & IsVisible

$
0
0

I'm having issues with binding in iOS. We have numerous forms in our app and they're broadly set out as per the example with an Entry and an associated label for validation feedback - we're using FluentValidation for this. The label is hidden unless there are errors to show, this is so they take up no space on the interace when not required.

<Entry x:Name="UsernameEntry" 
    Placeholder="{Binding UILabelLoginName}"
    IsTextPredictionEnabled="False"
    PlaceholderColor="#333333"
    TextColor="#000000" 
    ReturnType="Done"
        Text="{Binding LoginName.Value}"
        InputTransparent="False">
    <Entry.Behaviors>
        <behaviors:EventToCommandBehavior
            Command="{Binding ClearValidationCommand}"
            CommandParameter="LoginName"
            EventName="Focused" />
    </Entry.Behaviors>
</Entry>

<Label
    IsVisible="{Binding LoginName.IsValid, Converter={StaticResource InverseBoolean}}"
    Style="{StaticResource ErrorLabelStyle}"
        Text="{Binding LoginName.FirstError}" />

This works lovely in Android, in iOS though the binding to IsVisible crashes the app. If we set IsVisible to true as opposed to binding it and set a fixed HeightRequest then it works fine but I don't want empty labels taking up space within the forms.

Android - On Load

Android - On Error

iOS - On Load (IsVisible set to Binding)

iOS - On Error (IsVisible set to Binding)

  • Crash

iOS - On Load (IsVisible set to True)

iOS - On Error (IsVisible set to True)

The exception at the time of the crash is,

Object reference not set to an instance of an object

at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateClip () [0x00072] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:413
at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateNativeControl () [0x0006c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:386
at Xamarin.Forms.Platform.iOS.VisualElementTracker.HandlePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00064] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:97
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:461
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindablePropertyKey propertyKey, System.Object value) [0x0000e] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:318
at Xamarin.Forms.VisualElement.set_Height (System.Double value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:324
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x0001a] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1081
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:178
at Xamarin.Forms.TemplatedView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:29
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1083
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.View child, Xamarin.Forms.Rectangle region, Xamarin.Forms.SizeRequest childSizeRequest) [0x00225] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:319
at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00081] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:65
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/Foundation/NSAction.cs:152
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at xxxx.iOS.Application.Main (System.String[] args) [0x00002] in C:\xxxx\xxxx.iOS\Main.cs:19

Any guidance would be very much appreciated!

Thanks

how make app resposive design ios

$
0
0

I have an issue in header and footer in ios app
how to make design support different device iPhones like iPhone 11 or iPhone 5 or tablet
best regards


Xam.Plugin.Media Saving photo in both internal storage and SD card on Android

$
0
0

I use Xam.Plugin.Media Camera option. My app takes photo and uploads this photo to remote server. I want the user to choose whether can save the picture or not save on phone while they use Xam.Plugin.Media Camera option. So I did a basic ui for this. After the user's choice, I set SaveToAlbum (true or false) It works on iOS good. But on android it doesn't work on SD card.

After taking photo using " await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { } ) ", the following cases are belowing:

  • If "SaveToAlbum = true" and phone camera setting is SD card, Xam.Plugin.Media is save photo twice, one to internal storage and one to SD card. (it should save one photo just internal storage)
  • If "SaveToAlbum = true" and phone camera setting is internal storage, Xam.Plugin.Media is save photo twice, just internal storage. (it should save one photo just internal storage)
  • If "SaveToAlbum = false" and phone camera setting is SD card, Xam.Plugin.Media is save photo once, just SD card. (it should never save)
  • If "SaveToAlbum = false" and phone camera setting is internal storage, Xam.Plugin.Media is save photo once, just internal. (it should never save)

How can i fix this? Thank you.

I get warning that “Invalid Code Signing Entitlements” with Apple Distribution Profile

$
0
0

I have an app which is on AppStore. It is signed as ios distrubution.

After a while my certificates are expired on apple developer account. I revoked these and created again. And I started seeing two certificates (iOS Distribution and Distribution). I saw a warning that is "Distribution for use in Xcode 11 or later".

Now I will update my app on appstore but I can't sign it with "iOS Distrubution". Because my xcode version is 11.5.
When I choose "iOS Distrubition" on my provisioning profile I can't sign my app.
When I choose "Distrubition" on my provisioning profile I can sign my app. But in this case while I try to upload app to appstore, I get a warning that: ERROR ITMS-90046: "Invalid Code Signing Entitlements. Your application bundle's signature contains code signing entitlements that are not supported on iOS. Specifically, value 'Development' for key 'com.apple.developer.icloud-container-environment' in 'Payload/...' is not supported."

I looked up this issue and I added that to Entitlements.plist
com.apple.developer.icloud-container-environment
Production

But it did't work for me.

How can I fix that? I have to distribute my app to the store as soon as possible but i couldn't find any solution with this issue.
Please someone help me.

On Platform values for font ionicons.woff

$
0
0

Hi

I am using custom font ionicons.woff and have used below;

    <ResourceDictionary>
        <OnPlatform x:TypeArguments="x:String" x:Key="ionicons">
            <On Platform="Android"
              Value="ionicons.woff#Regular" />
            <On Platform="iOS"
              Value="ioniconsr" />
        </OnPlatform>
    </ResourceDictionary>

However this is not working. What are the correct 'On Platform' values for font ionicons.woff and in general what is the method to get these values for a given font.

Thanks

Regards

Mapped file has no Team ID and is not a platform binary ERROR IOS

$
0
0

Hello I am getting this error now please help xamarin after update have a lots of bugs

Launched application 'com.companyname.ooo' on '??? iPhone ?????????? ????ALOOOSH' with pid 643
dyld: Library not loaded: @rpath/FirebaseMessaging.framework/FirebaseMessaging
  Referenced from: /var/containers/Bundle/Application/Herer_was_long_Num/ooo.iOS.app/ooo.iOS
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/Herer_was_long_Num/ooo.iOS.app/Frameworks/FirebaseMessaging.framework/FirebaseMessaging: code signature in (/private/var/containers/Bundle/Application/Herer_was_long_Num/ooo.iOS.app/Frameworks/FirebaseMessaging.framework/FirebaseMessaging) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)
Xamarin.Hosting: Process '643' exited.
Application 'com.companyname.ooo' terminated.

Animating scrollview items appear & disappear.

$
0
0

I'm trying to create some animations inside a CollectionView. This is when the items are added or when the items are removed.
I have looked for some animations tutorials however I have not seen an example being applied to the items inside the collectionview, how could I animate them?

Thanks!

output console data to ui in xamarin.forms

$
0
0

I'd like to be able to send the Application Output / debug info to an entry box (or whatever works).

I tried using an Editor with and rerouting the console.out to it, but there seem to be major roadblocks with vague documentation. How can I catch this data and send it to my ui?

Thanks for reading :#

Where is $(MSBuildExtensionsPath) located?

$
0
0

When creating a iOS Library porject and opening the csproj file I see <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> in the bottom. What is $(MSBuildExtensionsPath)and what is location of it?


Why does archiving break the build?

$
0
0

Hi all,

I'm publishing my first app to the internal test track.

When I build for release and run in the emulator, the app plays nicely. After archiving the app ready for distribution, if I run the app locally again it crashes. I discovered this after finding that in the pre-launch report in the Play Console, the app crashed on launch on all devices.

On first launch, the app copies 2 json files from the assets folder to the app directory. These files aren't being found in the assets directory.

I've noticed that if, before uploading to the Play Console, I clear out the bin and obj folders before building and archiving, the build works and the pre-launch report shows no errors.

The process seems very fragile to me. Why should it be necessary to clear out the build folders before archiving? So my question is whether this is a bug or whether I've got something wrong?

My build setting:

Printerest like CollectionView renderer for iOS in Xamarin.Forms?

$
0
0

After some research I could find the custom renderer for CollectionView in Android and it works great, but I couldn't find the equalant for iOS. Please help me create it for iOS. Thanks

Custom CollectionView for android:

[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace App.Droid
{
    public class CustomCollectionViewRenderer : CollectionViewRenderer
    {
        public CustomCollectionViewRenderer(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<ItemsView> elementChangedEvent)
        {
            base.OnElementChanged(elementChangedEvent);

            if (elementChangedEvent.NewElement != null)
            {
                StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.Vertical);
                SetLayoutManager(manager);
            }
        }
    }
}

Custom CollectionView for iOS: ??

Xamarin Forms: How to create an Epub Viewer in Xamarin Forms?

$
0
0

I am trying to implement an epub viewer in xamarin forms like the below video.

Video Link: https://drive.google.com/file/d/1jW33lstCXqwC35siYklLoXAxItWpQG8c/view?usp=sharing

At first, I need to show the TOC of the book. If taps any chapter in TOC need to show that chapter on the UI. The total chapters and current chapter details are added at the bottom of the page. We can change the font size, font style, light and dark theme, and horizontal and vertical swiping features. Also able to hear the chapter in audio voice. Please have a look at the above video.

This is the native Android implementation. I need to do this feature in xamarin forms, following are my queries.

  1. Is xamarin offer an epub viewer like this? Or I need to do all these features custom?
  2. I tried EpubReader.Cross NuGet package, but it has no TOC list.
  3. How can I change the font size and font style like the video?
  4. For audio voice feature I can use text to speech feature, but when reading the book by voice how can I highlight the text?
  5. There is a package named epubReader, it has a TOC list. But when I try to install it to the project, I am getting this error.

MakeTextWritingDirectionRightToLeft(null) in xamarin iOS

$
0
0

I'm trying to achieve RightToLeft direction in my project. Other things working fine but label isn't moving to right in iOS for that purpose i've created a LabelRenderer in which i'm passing this method MakeTextWritingDirectionRightToLeft(null) but i'm getting exception Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UILabel makeTextWritingDirectionRightToLeft:]: unrecognized selector sent to instance 0x7fd2fb68b680 kindly anybody let me know what to pass in the parameter of this function instead of null. Thanks

Content of a frame that is the View of a ViewCell appear on top of other rows in the list - iOS only

Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>