Picker 에서 UnderLine 제거하는 방법입니다.

BorderlessPicker.cs

namespace SuaveControls.MaterialForms
{
    public class BorderlessPicker : Picker
    {
    }
}

BorderlessPickerRenderer.cs – Android

[assembly: ExportRenderer(typeof(BorderlessPicker), typeof(BorderlessPickerRenderer))]
namespace SuaveControls.MaterialForms.Android.Renderers
{
    public class BorderlessPickerRenderer : PickerRenderer
    {
        public static void Init() { }
        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement == null)
            {
                Control.Background = null;
 
                var layoutParams = new MarginLayoutParams(Control.LayoutParameters);
                layoutParams.SetMargins(0, 0, 0, 0);
                LayoutParameters = layoutParams;
                Control.LayoutParameters = layoutParams;
                Control.SetPadding(0, 0, 0, 0);
                SetPadding(0, 0, 0, 0);
            }
        }
    }
}


BorderlessPickerRenderer.cs – iOS

[assembly: ExportRenderer(typeof(BorderlessPicker), typeof(BorderlessPickerRenderer))]
namespace SuaveControls.MaterialForms.iOS.Renderers
{
    public class BorderlessPickerRenderer : PickerRenderer
    {
        public static void Init() { }
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
 
            Control.Layer.BorderWidth = 0;
            Control.BorderStyle = UITextBorderStyle.None;
        }
    }

}



BorderlessPickerRenderer.cs – UWP

[assembly: ExportRenderer(typeof(BorderlessPicker), typeof(BorderlessPickerRenderer))]
 
namespace SuaveControls.MaterialForms.UWP.Renderers
{
    public class BorderlessPickerRenderer : PickerRenderer
    {
        public static void Init() { }
        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged(e);
 
            if (Control != null)
            {
                Control.BorderThickness = new Windows.UI.Xaml.Thickness(0);
                Control.Margin = new Windows.UI.Xaml.Thickness(0);
                Control.Padding = new Windows.UI.Xaml.Thickness(0);
            }
        }
    }

}


예전에 빌드 했던 앱을 열어서 Nuget 을 모두 업데이트 했는데 

아래 처럼 에러가 발생되었다.



unable to get provider com.google.android.gms.ads.mobileadsinitprovider: java.lang.illegalstateexception


해결방법은 AndroidManifest.xml 파일에

아래처럼 AdMob 에서 할당된 앱의 고유 ID 를 넣으면 해결된다.


<application android:label="UnitConversion" android:icon="@drawable/module48">

    <meta-data

        android:name="com.google.android.gms.ads.APPLICATION_ID"

        android:value="ca-app-pub-4681470946279796~5708961527"/>

</application>


앱의 ID 는 AdMob 사이트에서 아래 처럼 확인 할 수 있다.


이전에는 저 항목이 없어도 광고 표시에 문제가 없었는데 버전업이 되면서 필수 항목으로 바뀐듯하다.



https://docs.microsoft.com/ko-kr/xamarin/get-started/tutorials/

Package Summary:

 

1 package(s) were not uploaded because they had problems:

/var/folders/n8/1kztj15176g1mt3hb4m4rr780000gn/T/BDC154E6-D0DD-43C1-84E5-8B9720D0CA85/1482499510.itmsp - Error Messages:

ERROR ITMS-90717: "Invalid App Store Icon. The App Store Icon in the asset catalog in '**.iOS.app' can't be transparent nor contain an alpha channel."

2019-10-28 01:37:31.401 altool[2620:38440] *** Error: Errors uploading 'Desktop/**.iOS.ipa': (

    "Error Domain=ITunesTransporterErrorDomain Code=-18000 \"ERROR ITMS-90717: \"Invalid App Store Icon. The App Store Icon in the asset catalog in '**QR.iOS.app' can't be transparent nor contain an alpha channel.\"\" UserInfo={NSLocalizedRecoverySuggestion=ERROR ITMS-90717: \"Invalid App Store Icon. The App Store Icon in the asset catalog in '**QR.iOS.app' can't be transparent nor contain an alpha channel.\", NSLocalizedDescription=ERROR ITMS-90717: \"Invalid App Store Icon. The App Store Icon in the asset catalog in '**QR.iOS.app' can't be transparent nor contain an alpha channel.\", NSLocalizedFailureReason=ERROR ITMS-90717: \"Invalid App Store Icon. The App Store Icon in the asset catalog in '**QR.iOS.app' can't be transparent nor contain an alpha channel.\"}"

)


앱 아이콘(AppIcon.appiconset)에 투명도가 있다면 발생되는 에러로 아이콘의 투명도를 모두 제거 하면된다.


Visual Studio 를 이용해 ipa 파일을 생성하고 Application Loader 를 이용해 

ipa 파일을 업로드 하려는데... 아무리 찾아도 보이지 않아 확인해보니

xcode 11 버전 부터 Application Loader 를 지원하지 않는다고 한다..

(맥미니를 새로 구입하면서.. 이런상황이...)


1. 앱 암호를 생성해야한다.

https://appleid.apple.com/account/manage

위 사이트로 들어가 로그인하고 보안 섹션의 앱암호 에서 암호 생성을 하고 기억한다.

(참고로 암호는 내가 지정하는것이 아니라 내가 특정 단어를 입력하면 단어 기준으로 암호가 만들어진다.)


2. 터미널을 실행히야 엡을 업로드 한다.

유틸리티에서 터미널을 실행하고


아래 명령어를 실행한다.

(바탕화면에 ipa 파일이 있다는 가정이다.)

xcrun altool --upload-app --type ios --file "Desktop/kjun.iOS.ipa" --username "ios 계정(메일)" --password "앱암호"


아래처럼 업로드 완료



  1. 사파리 앱으로 http://get.udid.io/ 에 들어갑니다.

  2. 녹색 버튼인 "Tap to find UDID" 를 클릭하시면 "Get Your UDID" 프로파일이 다운로드 되고 설정에 들어가서 프로파일을 설치합니다. 설치하시면 자동으로 해당 사이트로 방문하며 UDID 정보가 나옵니다.


기기 디버깅 시도를 하는데 아래와 같이 에러가 발생되었다.

 

심각도 코드 설명 프로젝트 파일 줄 비표시 오류(Suppression) 상태

오류 AggregateException: 하나 이상의 오류가 발생했습니다.

            MessagingException: The post for client build22112kjun on topic xvs/Build/4.12.3.83/execute-task/LottoManager.iOS/463b046002fCodesign has been cancelled

            TaskCanceledException: 작업이 취소되었습니다. LottoManager.iOS

 

해결방법

1. 맥을 재부팅

2. PC도 재부팅

3. iOS 프로젝트의 bin, obj 폴더 삭제

4. 프로젝트 정리

5. 다시 빌드

6. 디버깅

 

* 3,4,5만 해도 해결이 될듯한데 이렇게도 안되면 재부팅해보는 걸 추천한다.

 

참고

https://stackoverflow.com/questions/39871336/xamarin-ios-the-post-for-client-build-has-been-cancelled

맥미니 2014 를 구매하고

소프트웨어 업데이트를 진행하기 위해 App Store 를 로그인하려는데

보안 코드가 아이폰으로 오는데

보안코드를 입력하는 화면이 뜨지 않았다.

문제가 있는건가 싶어 헤맸는데..

계정비번 뒤로 보안코드를 붙이는거였다.;;;

 

비번이 KJUN 일때

보안코드가 123456 이라면

KJUN123456

이렇게 비번 뒤쪽으로 보안코드를 붙여서 로그인하면 된다.

Xamarin Forms 의 Picker 에서 SelectedIndexChanged 이벤트를 걸어 놓으면

Android 는 확인 버튼을 클릭했을때 동작하는데

iOS 는 Done 을 선택하기전 값을 바꾸는 와중에 SelectedIndexChanged 이벤트가 발생했다.

이를 막고 Done 버튼을 클릭(선택완료 시) SelectedIndexChanged 이벤트를 타게 하려면 아래와 같이 코딩해야한다.

 

using Xamarin.Forms.PlatformConfiguration;

using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

 

this.picker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);

 

원본

https://www.xamarinexpert.it/admob-made-easy/

 

 

In this tutorial I’ll show you how to monetize your Xamarin apps with AdMob using my MTAdmob plugin.

Important: If you receive errors compiling the code for iOS, install the package Xamarin.Google.iOS.MobileAds in your iOS project.

UPDATE 1/May/2019: I’ve released the new version 1.3 thas sovles some issues with iOS and improves performances.

UPDATE: From version 1.2, MTAdmob supports also Google ads rewarded videos for Android and iOS

UPDATE: I’ve added on github the source code of a project to test this Admob plugin. You can find it here: https://github.com/marcojak/TestMTAdmob

To help you to speed up your Xamarin development, I’ve created a set of plugins, one of them is MTAdmob. Thanks to this plugin you can add Admob banners and Insterstitials in just few lines of code. It couldn’t be easier than that and I’ll show you.

Install the plugin

First of all, right click on your Xamarin solution and select “Manage Nuget packages for Solution”

Visual Studio will open a new screen where you can search and install one or more nuget packages. In this case we can search for the MTAdmob plugin. Searching for MarcTron will show you all my packages (I’m sure you can find other useful plugins that I’ve written), and we can select the MTAdmob plugin as showed in the next image.

It’s very important that you install the plugin in your PCL/.Net standard project and in your platform projects (Android, iOS, UWP).

After the Admob plugin is installed we can add banners and insterstitials to our projects.

Add Ads to our project

With version 1.0 the MTAdmob plugin supports banner and interstitials for Android and iOS. If you would like to see the plugin supporting also the UWP platform, let me now and I’ll add the support in a new version.

As I’ve said we can add Banners and Interstitials Admob ads to our project. Let’s start with the Banners

How to add an Admob Banner

An Admob banner is just a view inside our page. It means that we can add it using XAML or C#. First of all let’s see how to add an Admob banner using XAML.

Add an Admob Banner with XAML

In MTAdmob to use an Admob banner I’ve created a custom control called AdView, so to use it we can use this code:

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

             xmlns:controls="clr-namespace:MarcTron.Plugin.Controls;assembly=Plugin.MtAdmob"

             x:Class="Test.MTAdmob.MainPage">

 

<StackLayout>

    <Label Text="Let's test an Admob Banner!"

           HorizontalOptions="Center"

           VerticalOptions="CenterAndExpand" />

    <!-- Place the Admob controls here -->

    <controls:MTAdView></controls:MTAdView>

</StackLayout>

In this example we have created a StackLayout with 2 controls: a label and an AdView (our Admob banner). Easy! Isn’t it???

The AdView control is basically a View so you can use all the properties you can think of like: HorizontalOptions, VerticalOptions, IsVisible…

In addition to these properties, I’ve added in AdView two other properties: AdsId and PersonalizedAds.

AdsId: Allows you to add the Banner Id (you can find it in your Admob account)

PersonalizedAds: This allow you to use non personalized ads. For example in case of GPDR. Of course it’s better to use personalized Ads.

To use these properties you can update the previous code to:

<controls:AdView PersonalizedAds="true" AdsId="xxxxxxxxxxxxxxxxxx"></controls:AdView>

Add an Admob Banner with C#

In case you don’t write your pages with XAML or you write your UI in C# or you want to add your view only in some cases, you can add your Admob Banner using this code:

using MarcTron.Plugin;

...

MTAdView ads = new MTAdView();

Of course you need to attach this View to your layout, but you know how to do it (If not, feel free to ask).

To use the custom properties you can change the previous code to:

...

MTAdView ads = new MTAdView();

ads.AdsId = "xxx";

ads.PersonalizedAds = true;

Also in this case, to add an Admob banner is INCREDIBILY EASY!!!

Global Custom Properties

As you have seen, the properties AdsId and PersonalizedAds belong to a single AdView. It means that you have to set them for every Admob Banner.

To make things even easier I’ve added the option to set these properties only once. To do so, you can use this C# code:

CrossMTAdmob.Current.UserPersonalizedAds = true;

CrossMTAdmob.Current.AdsId = "xxxxxxxxxxxxxxxx";

In this case all your Admob banner will show personalized ads and will have the same Id.

If you set local and global properties, the local ones will have higher priority.

Use of Banner Events

I’ve added 4 events to the Admob banner that you could find nice to have. These events are:

  • AdsClicked When a user clicks on the ads
  • AdsClosed When the user closes the ads
  • AdsImpression Called when an impression is recorded for an ad.
  • AdsOpened When the ads is opened

To use these events you can write this code:

AdView myAds = new AdView();

myAds.AdsClicked += MyAdsAdsClicked;

myAds.AdsClosed += MyAds_AdVClosed;

myAds.AdsImpression += MyAds_AdVImpression;

myAds.AdsOpened += MyAds_AdVOpened;

Of course you can use these events also if you have declared your AdView in your XAML code.

Admob Interstitials

Now that we know how to add Admob banners using my plugin MTAdmob, let’s see how we can add Admob Interstitials. If possible, to add an Admob interstitial is even easier. You just need a single line of code. Don’t you believe me? Look here how to show an Admob interstitial:

CrossMTAdmob.Current.ShowInterstitial("ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");

I told you!!! That’s it!!! With that line of code you have just showed an Interstitial in you app. Of course you need to replace that string with the Insterstitial ID you can find in your Admob account.

Events for Interstitials

There 3 events that you can use with Interstitials:

OnInterstitialLoaded        When it's loaded

OnInterstitialOpened        When it's opened      

OnInterstitialClosed        When it's closed

Rewarded Video

From version 1.1 the plugin supports the amazing Rewarded Video too.

To show a rewarded video you just need a single line of code:

CrossMTAdmob.Current.ShowRewardedVideo("xx-xxx-xxx-xxxxxxxxxxxxxxxxx/xxxxxxxxxx");

Events for Rewarded videos

There are 7 events that you can use with the Rewarded video Ads:

OnRewarded                          When the user gets a reward

OnRewardedVideoAdClosed             When the ads is closed

OnRewardedVideoAdFailedToLoad       When the ads fails to load

OnRewardedVideoAdLeftApplication    When the users leaves the application

OnRewardedVideoAdLoaded             When the ads is loaded

OnRewardedVideoAdOpened             When the ads is opened

OnRewardedVideoStarted              When the ads starts

Initialization

Before you can use the Admob banners and Interstitials, you need to initialize it. You need to do it only once so it makes sense to initialize it onside the OnCreate method in Android and FinishedLaunching in iOS.

In your Android project add this line in your OnCreate method:

MobileAds.Initialize(ApplicationContext, "ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx");

In your iOS project add this line in your FinishedLaunching method:

MobileAds.Configure("ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx");

If you receive errors compiling the code for iOS, install the package Xamarin.Google.iOS.MobileAds in your iOS project.

ANDROID PROJECT (IMPORTANT)

In your AndroidManifest you should add these lines:

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

 

<application android:label="Test.MTAdmob.Android">

    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>

    <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />

</application>

Some useful links

Conclusion

This Admob MTAdmob plugin is incredibly easy to use but in case you need help, or you want to suggest a new feature or for any other reason, write me.

 

+ Recent posts