OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

there is no definition of inFocusDisplayType ... #194

Closed thomiel closed 4 years ago

thomiel commented 4 years ago

Description:

There is no definition of inFocusDisplayType as shown in the Xamarin.Forms sample code on https://documentation.onesignal.com/docs/xamarin-sdk-setup (section 2.1A). Where did it move. How can I access the functionality in the current version?

Environment

Using version 3.8.2 in Visuals Studio 2019 on Windows.

Steps to Reproduce Issue:

  1. Add version 3.8.2 of the Xamarin SDK to your project in VS
  2. Insert sample code from the official OnSignal docs
  3. build the project

Anything else:

The sample code seems to be badly outdated. I had to correct severeal lines of code. For example, I had to change OneSignal.LOG_LEVEL.VERBOSE to Com.OneSignal.Abstractions.LOG_LEVEL.VERBOSE.

Would it be possible to update the docs? I would help Xamarin developers to quickly adapt OneSignal in their Xamarin projects, as advertised on the homepage.

This is my code:

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();
}
enkaradag commented 4 years ago

+1 here. want to get rid of those in-app notifications. could not find the reference. shall downgrading bring up them back?

enkaradag commented 4 years ago

Found. You can implement that like:

OneSignal.Current.StartInit("YOUR_ONESIGNAL_APP_ID") .Settings(new Dictionary<string, bool>() { { Com.OneSignal.Abstractions.IOSSettings.kOSSettingsKeyAutoPrompt, false }, { Com.OneSignal.Abstractions.IOSSettings.kOSSettingsKeyInAppLaunchURL, false } }) .InFocusDisplaying(OSInFocusDisplayOption.Notification) .EndInit();

thomiel commented 4 years ago

Cheers! I leave this open as a reminder to update the guide on the OneSignal website.

rgomezp commented 4 years ago

Howdy, Yes we will update the documentation with the correct method.

phamquan commented 4 years ago

Should be like this

        private void PrepareOneSignal()
        {
            //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>() {
                { IOSSettings.kOSSettingsKeyAutoPrompt, false },
                { IOSSettings.kOSSettingsKeyInAppLaunchURL, false } })
            .InFocusDisplaying(OSInFocusDisplayOption.Notification)
            .EndInit();

            // 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();
        }
rgomezp commented 4 years ago

The docs have been updated. Cheers

denzerd commented 4 years ago

The docs have been updated. Cheers

They have? Because here https://documentation.onesignal.com/docs/xamarin-sdk-setup it is still wrong.

rgomezp commented 4 years ago

Thanks for pointing that out. We have the code in several places so we appreciate you pointing that out. Enjoy!