【发布时间】:2020-04-30 11:37:07
【问题描述】:
https://documentation.onesignal.com/docs/xamarin-sdk-setup(第 2.1A 节)上的 Xamarin.Forms 示例代码似乎有点过时了。我不得不更改几个包对象,例如 OneSignal.LOG_LEVEL.VERBOSE 到 Com.OneSignal.Abstractions.LOG_LEVEL.VERBOSE。
我无法立即转换为当前 SDK 的一行代码:
OneSignal.inFocusDisplayType = Com.OneSignal.Abstractions.OSInFocusDisplayOption.Notification;
那么inFocusDisplayType 在 SDK 中移动到哪里了?
完整代码:
public partial class App : Xamarin.Forms.Application
{
public App ()
{
// The root page of your application
MainPage = new NavigationPage(new MyApp.LoggingInPage());
//Remove this method to stop OneSignal Debugging
OneSignal.Current.SetLogLevel(Com.OneSignal.Abstractions.LOG_LEVEL.VERBOSE, Com.OneSignal.Abstractions.LOG_LEVEL.NONE);
OneSignal.Current.StartInit("YOUR_ONESIGNAL_APP_ID")
.Settings(new Dictionary<string, bool>() {
{ Com.OneSignal.Abstractions.IOSSettings.kOSSettingsKeyAutoPrompt, false },
{ Com.OneSignal.Abstractions.IOSSettings.kOSSettingsKeyInAppLaunchURL, false } })
.EndInit();
OneSignal.inFocusDisplayType = Com.OneSignal.Abstractions.OSInFocusDisplayOption.Notification;
// ^^^^^^^^^^^^^^^^^^ ??
// The promptForPushNotificationsWithUserResponse function will show the iOS push notification prompt. We recommend removing the following code and instead using an In-App Message to prompt for notification permission (See step 7)
OneSignal.Current.RegisterForPushNotifications();
}
【问题讨论】:
-
他们有github,但我在那里找不到
inFocusDisplayType。如果您在此处没有得到答案,您可以提出问题并在此处询问。
标签: xamarin xamarin.forms push-notification onesignal