Git Product home page Git Product logo

Comments (5)

sergio11 avatar sergio11 commented on June 1, 2024

I forgot to comment, that the call to PushNotificationManager.ProcessIntent (Intent); I do not do it in the main activity since this is of type MvxSplashScreenActivity. This call I make in a second activity after initializing Xamarin.Forms and loading the application.

from pushnotificationplugin.

rdelrosario avatar rdelrosario commented on June 1, 2024

Check the FAQ section to fix your issue:
https://github.com/CrossGeeks/PushNotificationPlugin/blob/master/docs/FAQ.md

Also the ProcessIntent call should be done on your MainLauncher activity so if you have a splash that might be were you need to do that call

from pushnotificationplugin.

steurt avatar steurt commented on June 1, 2024

@sergio11
This is actually the result of a known Xamarin.Android bug and not of this library.
For more details see this thread.

Try cleaning your solution and your Xamarin.Android project and building again.
Also you can try the workaround as described in comment 13 of the bug report.

from pushnotificationplugin.

sergio11 avatar sergio11 commented on June 1, 2024

Thank you so much,

it seems that my problem was that I needed to add

<Target Name="RemoveGoogleServicesJsonStampFiles" BeforeTargets="BeforeBuild">
    <Delete Files="$(IntermediateOutputPath)\ProcessGoogleServicesJson.stamp" />
  </Target>

to my Android project file.

Now works perfect.

from pushnotificationplugin.

sergio11 avatar sergio11 commented on June 1, 2024

I've got it working in an application similar to the example. It works perfect. The problem is when I have a main activity of type SplashScreen.

[Activity(
		Name = "com.usal.bisite.bulltect.SplashScreen",
		Label = "bulltect"
		, MainLauncher = true
		, Icon = "@mipmap/ic_launcher"
		, Theme = "@style/Theme.Splash"
		, NoHistory = true
		, ScreenOrientation = ScreenOrientation.Portrait)]
	public class SplashScreen : MvxSplashScreenActivity
	{


		protected override void TriggerFirstNavigate()
		{
			StartActivity(typeof(MvxFormsApplicationActivity));
		}
	}

which then initiates another activity where Xamarin Forms is initialized and the application:

[Activity(
        Name = "com.usal.bisite.bulltect.MvxFormsApplicationActivity",
        Label = "bulltect",
        Icon = "@mipmap/ic_launcher",
        Theme = "@style/AppTheme",
        MainLauncher = false,
		LaunchMode = LaunchMode.SingleTask,
        ScreenOrientation = ScreenOrientation.Portrait
    )]
    public class MvxFormsApplicationActivity : FormsAppCompatActivity
    {

		MvxFormsApplication _formsApplication;
		protected MvxFormsApplication FormsApplication
		{
			get
			{
				if (_formsApplication == null)
				{
					var formsPresenter = (IMvxFormsPagePresenter)Mvx.Resolve<IMvxAndroidViewPresenter>();
					_formsApplication = formsPresenter.FormsApplication;
				}
				return _formsApplication;
			}
		}


        protected override void OnCreate(Bundle bundle)
        {
			try
			{
    			ToolbarResource = Resource.Layout.Toolbar;
    			TabLayoutResource = Resource.Layout.Tabs;

    			base.OnCreate(bundle);

    			// Required for proper Push notifications handling
    			var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);
    			setupSingleton.EnsureInitialized();

                global::Xamarin.Forms.Forms.Init(this, bundle);
                GrialKit.Init(this, "Bullytect.Droid.GrialLicense");

				// Presenters Initialization
				global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, bundle);

				// Xamarin.Auth CustomTabs Initialization/Customisation
				global::Xamarin.Auth.CustomTabsConfiguration.ActionLabel = null;
				global::Xamarin.Auth.CustomTabsConfiguration.MenuItemTitle = null;
				global::Xamarin.Auth.CustomTabsConfiguration.AreAnimationsUsed = true;
				global::Xamarin.Auth.CustomTabsConfiguration.IsShowTitleUsed = false;
				global::Xamarin.Auth.CustomTabsConfiguration.IsUrlBarHidingUsed = false;
				global::Xamarin.Auth.CustomTabsConfiguration.IsCloseButtonIconUsed = false;
				global::Xamarin.Auth.CustomTabsConfiguration.IsActionButtonUsed = false;
				global::Xamarin.Auth.CustomTabsConfiguration.IsActionBarToolbarIconUsed = false;
				global::Xamarin.Auth.CustomTabsConfiguration.IsDefaultShareMenuItemUsed = false;

				global::Android.Graphics.Color color_xamarin_blue;
				color_xamarin_blue = new global::Android.Graphics.Color(0x34, 0x98, 0xdb);
				global::Xamarin.Auth.CustomTabsConfiguration.ToolbarColor = color_xamarin_blue;


				// ActivityFlags for tweaking closing of CustomTabs
				// please report findings!
				global::Xamarin.Auth.CustomTabsConfiguration.
				   ActivityFlags =
						global::Android.Content.ActivityFlags.NoHistory
						|
						global::Android.Content.ActivityFlags.SingleTop
						|
						global::Android.Content.ActivityFlags.NewTask
						;

				global::Xamarin.Auth.CustomTabsConfiguration.IsWarmUpUsed = true;
				global::Xamarin.Auth.CustomTabsConfiguration.IsPrefetchUsed = true;

    			UserDialogs.Init(this);
    			PullToRefreshLayoutRenderer.Init();
    			XFGloss.Droid.Library.Init(this, bundle);
    			//Initializing FFImageLoading
    			CachedImageRenderer.Init();
                CarouselViewRenderer.Init();
    			FormsHelper.ForceLoadingAssemblyContainingType(typeof(UXDivers.Effects.Effects));

                LoadApplication(FormsApplication);
                PushNotificationManager.ProcessIntent(Intent);

    			var starter = Mvx.Resolve<IMvxAppStart>();
    			starter.Start();

            }
            catch (Exception e)
			{

				System.Diagnostics.Debug.WriteLine("**BullTect LAUNCH EXCEPTION**\n\n" + e);
			}


		}

		public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
		{
			base.OnConfigurationChanged(newConfig);

			DeviceOrientationLocator.NotifyOrientationChanged();
		}

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
}

I have placed the call PushNotificationManager.ProcessIntent (Intent); in both activities. But it does not work. When I send the notification to the device the first time it tells me that it has been sent correctly. The next few times tell me ""error": "NotRegistered""

Would you know what the problem might be?

from pushnotificationplugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.