Tag: ios

Xamarin – Did not find reference matching RestoreAssemblyResources AssemblyName metadata

Did you recently remove a package, but Visual Studio insists it’s there? Or did you readd it and VS seems to disagree? People on the Xamarin Forums tend to get good luck cleaning/rebuilding, and it miraculously starts working again for them. I wasn’t so fortunate and wasted a lot of time taking their word for it.

 

My exact error message

Error Did not find reference matching RestoreAssemblyResources AssemblyName metadata 'Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' iosTests

If you’re like me, you’ve tried readding the package, modifying your packages.config file and still nothing is working

Here’s what you need to do:

  1. Locate your  .csproj file and open it in a text editor (Double clicking opens it in VS)
  2. Press CNTRL + F and search for the offending library
  3. Comment out the entry or delete it
  4. Build the project again (Since it’s Xamarin, it will take a lifetime to build) and it will hopefully work again!
  5. Success! 

I spent days trying to figure this out. When we as Xamarin developers run into issues like this, we need to share our solutions since there is little to no support from Xamarin. I hope all my fellow Xamarin developers will find this useful!

Displaying AdMob ads on iOS with Xamarin Forms!

All the tutorials on displaying ads on iOS are currently broken, as the package used to display ads has been removed.

There is a new package, however the usage example it gives is for an iOS dependent project. It will not work/compile for use in Xamarin Forms

The approach is the same however, You are rendering a View you declare in your portable project

Install the correct ad package, it should look like this in Nuget Package Manager

xamarin

Here is the view I created in my Xamarin Forms project.

namespace CanadianClassifiedsAlerter
{
    public class AdMobView : View
    {
        public AdMobView() { }
    }
}

In my iOS project, I created a ViewRenderer.

[assembly: ExportRenderer(typeof(AdMobView), typeof(AdMobRenderer))]
namespace CanadianClassifiedsAlerter.iOS
{
    public class AdMobRenderer : Xamarin.Forms.Platform.iOS.ViewRenderer
    {
        const string bannerId = "THISISWHEREMY_AD_IDGOES";

        BannerView adView;
        bool viewOnScreen = false;

        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);
            // Setup your BannerView, review AdSizeCons class for more Ad sizes. 
            adView = new BannerView(size: AdSizeCons.Banner, origin: new CGPoint(-10, 0))
            {
                AdUnitID = bannerId,
                RootViewController = UIApplication.SharedApplication.Windows[0].RootViewController
            };

            // Wire AdReceived event to know when the Ad is ready to be displayed
            adView.AdReceived += (object sender, EventArgs ea) => {
               
                viewOnScreen = true;
            };

            adView.LoadRequest(Request.GetDefaultRequest());
            base.SetNativeControl(adView);
        }
    }


}

Now, after all is said and done to add it to my page, it’s this simple!

 

 mainLayout.Children.Add(new AdMobView
            {
                WidthRequest = 320,
                HeightRequest = 50
            });

Your end result should look like this

iosAdmobFinalResult

EDIT: Sample project files are here

Unused Canadian Classifieds Portable Project Files (Xamarin Forms).

I decided to use Xamarin.iOS instead for this project, so feel free to do whatever with those files.

 

EDIT: A user followed the advice from this article and got the following error…

“Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[AppDelegate window]: unrecognized selector sent to instance 0x79aa9b10”

He override the Window with the following code and away it worked!

public override UIWindow Window {
get
{
return UIApplication.SharedApplication.KeyWindow;
}
}

How to get instant alerts from Kijiji – Canadian Classifieds Alerter

You’ve tried using Kijiji’s daily alerts. The issue with them… is that they come daily. As in once a day, when everyone else gets them, meaning you have no more advantage than anyone else. The worst part is… sometimes they don’t even get sent at all.

The solution

If you have an Android device, you can download “Canadian Classifieds Alerter” from the google play store.

Or you can download the iPhone/iOS version on the Apple Store

What does it do?

Canadian Classifieds Alerter checks Kijiji for you! Let’s say you are looking for an iPhone and you’re on a budget of $200. Simply set an alert to check for “iPhone” and a price limit of $200 and you will be notified the next time someone posts it on Kijiji… before anyone else!

Where can I get it and does it cost money?

It is available on Google play and the Apple app store for the low cost of FREE!

How do I setup an alert?

(These steps are for an outdated Android version, iOS/iPhone version and newer Android versions will be very similar!)

Glad you asked and that you’re on board. Let’s walk through the steps… I am going to assume you know to download an application from Google Play or Amazon. Because of how their search is setup, you may have to search for “Canadian Classifieds Alerter” all in quotes. If not, just click this link for Google Play or this link for Amazon on your Android smartphone/tablet.

(These screenshots are from an earlier version of the app. The steps are still the same)

Step 1. Click “New Alert”

The New Alert screen will then be displayed

Click on "New Alert"

Click on “New Alert”

 

Step 2. Select a Category and Location

Clicking through the buttons will traverse you through categories, and categories within categories. The same goes for location. For this example, I am picking “Cellphones” in the “Phones” category and I will be searching in Moncton, New Brunswick. If you make a mistake, don’t sweat it, just press the back button.

step2

 

Step 3. (Optional) Enter a search query and a maximum price

While this part is optional, I highly recommend it just so you aren’t bombarded with notifications with things you don’t care about, or things out of your price range. In the maximum  price field, enter the most you’re willing to pay (ie, 200) and enter a search query in the “Search for” box (In this case, “iphone”).

step3

Step 4. Press “ADD ALERT”

Self-explanatory.

step4

And just like that you’re brought to the main screen and your notification is now there

step5

Step 5. Close the application and wait.

There is a background service running that does all the checking for you… sit tight. The more specific your search is, the less results you get. It’s worth mentioning that by default, it will not check unless you’re on wifi. Go into the settings to change this. Want a rundown of all the settings? Check out my blog post on how to do that!

Step 6. You got an alert! Hurry and jump on it!

step6

Wow, that was fast! Touch the notification and the Notifications screen will appear… click “GO TO AD” to open the ad in your browser

 

step7

Check the ad out, if you like it, then contact the seller!

step8

 

Want more information? Check out these posts:

Canadian Classifieds Alerter – How to customize and configure to your liking – Rundown of the app settings
Canadian Classifieds Alerter –  Frequently Asked Questions (FAQ)