I have been trying to integrate Facebook Audience Network so as to load native ads in my Xamarin Native iOS application. When I debug my application the code enters method "NativeAdDidFail" and the NSError says "No fill" and No other information is printed in the console.
This is what I have done:
Created a resource in business manager and Selected iOS as the target platform.
I left out the payment/mediation and app store URL since my app is not published.
Added an ad placement for native ads and Added one test device in the Monetization manager by adding my iphones IDFA.
Enabled testing, Checked the checkbox for "use real ads", I also clicked on the "choose ad type" but it doesnt seem to be saved?
Added one test user in business manager and Assigned access to the created property.
Downloaded native Facebook app and Enabled tracking in the background for the native facebook app.
Logged in on the native app with the email of the test user that I added.
Added "SkadNetworkIdentifier" and LSApplicationQueriesSchemes in info.plist-> v9wttpbfk9.skadnetwork & n38lu8286q.skadnetwork
Downloaded Xamarin.Facebook.Audiencenetwork.ios
This is my code:
AdSettings.SetAdvertiserTrackingEnabled(false);
AdSettings.ClearTestDevices();
AdSettings.AddTestDevice("74312C38-4958-4187-B385-9FCFE68FRRA9");
nativeAd = new NativeAd("CAROUSEL_IMG_SQUARE_LINK#611875720420055_511995483752412")
{ Delegate = this };
nativeAd.LoadAd();
[Export("nativeAdDidLoad:")]
public void NativeAdDidLoad(NativeAd nativeAd)
{
}
[Export("nativeAd:didFailWithError:")]
public void NativeAdDidFail(NativeAd nativeAd, NSError error)
{
var errorcode = error.Code;
Console.WriteLine($"{nameof(NativeAdDidFail)} - Native ad failed to load with error: {error.LocalizedDescription}");
//AppDelegate.ShowMessage("Native Ad Error", error.LocalizedDescription, NavigationController);
}
[Export("nativeAdDidClick:")]
public void NativeAdDidClick(NativeAd nativeAd) =>
Console.WriteLine($"{nameof(NativeAdDidClick)} - Native ad was clicked.");
[Export("nativeAdDidFinishHandlingClick:")]
public void NativeAdDidFinishHandlingClick(NativeAd nativeAd) =>
Console.WriteLine($"{nameof(NativeAdDidFinishHandlingClick)} - Native ad did finish click handling.");
[Export("nativeAdWillLogImpression:")]
public void NativeAdWillLogImpression(NativeAd nativeAd) =>
Console.WriteLine($"{nameof(NativeAdWillLogImpression)} - Native ad impression is being captured.");
Here's the tutorial I am trying to follow
According to the Facebook Audience Network, this could be the possible reasons:
Related
As we know, Android 13 is introducing runtime notification permission. Here's the Android developer documentation on this.
We already have a priming page where we show the notification permission prompt in iOS. We just need to do this for all users on Android 13.
After reading the documentation, i've added the following:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
However I can't seem to find a way to prompt Android users. Has anyone had any success with this/can point me in the right direction?
Also, we've noticed all of our users who have upgraded to Android 13 have notifications turned off by default. Is there a way we can add a link to the notifications permission in the settings?
I am currently using this to achieve that, in your MainActivity put this
protected override void OnStart()
{
base.OnStart();
const int requestLocationId = 0;
string[] notiPermission =
{
Manifest.Permission.PostNotifications
};
if ((int)Build.VERSION.SdkInt < 33) return;
if (this.CheckSelfPermission(Manifest.Permission.PostNotifications) != Permission.Granted)
{
this.RequestPermissions(notiPermission, requestLocationId);
}
}
From document Notification runtime permission, we know that:
To request the new notification permission from your app, update your
app to target Android 13 and complete a similar process compared to
requesting other runtime permissions.
And from document POST_NOTIFICATIONS, we also find that :
POST_NOTIFICATIONS Added in API level 33
public static final String POST_NOTIFICATIONS Allows an app to post
notifications
Protection level: dangerous
Constant Value: "android.permission.POST_NOTIFICATIONS"
That is the Protection level of POST_NOTIFICATIONS is dangerous, so we need to
add Requesting Runtime Permissions.
For more information, you can check : Requesting Runtime Permissions in Android Marshmallow.
You can also check Permissions In Xamarin.Android here.
And there is a sample here:https://github.com/xamarin/monodroid-samples/tree/main/android-m/RuntimePermissions.
I have a finished application which I would like to make available to run on the iOS and Android platforms. I have tested the application as much as possible and it works without problem. But I know there is always the chance that something might go wrong and I could get an exception.
My question is how can I deal with this or what should I do. What happens on the phone, if a Forms application is deployed and there is an exception.
Would appreciate any advice or even links as to how this is handled.
If an exception is thrown and not handled by your code, the app will stop working (i.e. crash).
In order to handle these crashes we are using MS AppCenter (the successor to HockeyApp/Xamarin AppInsights).
You'll have to create a project there (one for each platform), and add the NuGet package to your projects. Afterwards you can initialize it with
AppCenter.Start("ios={Your App Secret};android={Your App Secret}",
typeof(Crashes)); // you'll get the app secrets from appcenter.ms
Crashes will be logged to AppCenter now and you'll be informed whenever there is a new crash.
Please note that it's best practice (if not required by law), that you ask the user for consent before sending the crash report (see here). You are using the delegate Crashes.ShouldAwaitUserConfirmation for that matter. You could for example show an action sheet with Acr.UserDialogs
private bool AwaitUserConfirmation()
{
// you should of course use your own strings
UserDialogs.Instance.ActionSheet(
new ActionSheetConfig
{
Title = "Oopsie",
Message = "The app crashed. Send crash to developers.",
Options = new List<ActionSheetOption>
{
new ActionSheetOption("Sure", () => Crashes.NotifyUserConfirmation(UserConfirmation.Send)),
new ActionSheetOption("Yepp, and don't bug be again.", () => Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend)),
new ActionSheetOption("Nope", () => Crashes.NotifyUserConfirmation(UserConfirmation.DontSend))
}
});
return true;
}
I am developing game for windows phone in unity3d, I have inserted Rate me button in game but on run time in windows phone it didn't work, is there any method to access AppID for the current application running in windows phone developed in Unity3d. I need code in unity3d CSharp for getting AppID.
I tried this C# code in Unity but It didn't work and having error no keywork found windows.
string appId = Windows.ApplicationModel.Store.CurrentApp.AppId.ToString();
LinkUri = new Uri("http://www.windowsphone.com/s?appid=" + appId, UriKind.Absolute)
Here I needed AppID to complete my link for rate me.
As far as i know Unity can not access the Windows namespace but you can make use of EventHandler to call 'Review Task' from Unity. You can do this by following below steps(visit Unity Expert for detailed explanation).
In Unity Game Engine-
Create Event -
using UnityEngine;
using System;
public static class events
{
//Create a new event
public static event EventHandler RateUs;
public static void FireRateUs()
{
Debug.Log ("Opening Rate Task......");
//If event is subscribed than fire it
if(RateUs!=null)
RateUs(null,null);
}
}
Fire Event -
using UnityEngine;
public class RateUs : MonoBehaviour
{
void OnMouseDown()
{
events.FireRateUs();
}
}
In Visual Studio IDE
Subscribe Event -
public MainPage()
{
.
.
.
.
events.RateUs += events_RateUs;
}
Call Function -
void events_RateUs(object sender, EventArgs e)
{
String AppId = Windows.ApplicationModel.Store.CurrentApp.AppId.ToString();
Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:reviewapp?appid=" + AppId));
}
You have to get your AppID from your developer's portal on Microsoft Create's web page. You can then hardcode it into your app or save it as a static/globally available variable for accessing purposes. This would mean you would have to begin the process of creating your app entry prior to the programming of the rating game feature. Just create the entry, and don't submit it! Or create it, and add Rate app as an update. I'd choose the former method, personally!
For Apple and Google rating/submit information you have to create the entry ahead of time to get a SKU number. Also in iTunes/Apple/iOS/OSX you have to create the app and give it a unique name, etc in the developer's portal/certificate store.
I am working on facebook authentication in a Xamarin forms app and want to use "native" login on each device.
The Facebook SDK (by Xamarin) is not designed for forms since it requires passing in an Android activity that implements some specific interfaces.
However; I was able to get the UI to display using a custom page renderer and then in that renderer calling StartActitivty with an activity that uses the exact implementation described in the Facebook SDK getting started. https://components.xamarin.com/view/facebookandroid
So far everything works perfect. The android app starts, xamarin forms kicks in, the custom page renderer is loaded the login android activity starts and the user logs in with facebook and we get to the console.writeline below.
So, how do I dismiss this intent or otherwise get back to xamarin forms?
Do I:
Dismiss this intent? - if so then what?
Inject something to "reset" the main page?
Other?
public void OnCompleted (Xamarin.Facebook.Model.IGraphUser user, Response response)
{
//TODO: show user details with welcome and button that takes them to main app.
//TODO: switch back to xam forms from here on out.
//TODO: figure out how to change the `main` activity to xam forms.
// 'Me' request callback
if (user != null) {
//How do I get back to Xamarin forms from here?
Console.WriteLine ("GOT USER: " + user.Name);
} else {
Console.WriteLine ("Failed to get 'me'!");
}
}
You should call Finish();
Anyway, if you want to see exactly how I did it, you can check it here:
https://github.com/IdoTene/XamarinFormsNativeFacebook
I submit my app on windows-phone7 store, Microsoft need following requirement to certify the app.
The following requirements apply to applications that receive the location of a user's mobile device:
2.7.1 Your application must determine location using Microsoft Location Service API.
2.7.2 The privacy policy of your application must inform users about how location data from the Location Service API is used and disclosed and the controls that users have over the use and sharing
of location data. This can be hosted within or directly linked from the application.
Please help me what i want to mentioned or implement to certify the app.
Here is the code I use to get the location.
private static GeoCoordinateWatcher Watcher;
private void StartGeoWatcher()
{
if (Watcher == null)
{
Watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
Watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(OnPositionChanged);
Watcher.TryStart(false, System.TimeSpan.FromMilliseconds(1000));
}
}
private void OnPositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
latitude = e.Position.Location.Latitude;
longitude = e.Position.Location.Longitude;
}