Base solution for your next web application
Open Closed

Notification Badge only updates on page refresh #9899


User avatar
0
devinedon created

ANC : 9.3.0

Hey,

Everything else works really well! From ingesting data into tables (via appNotifier) to showing on the UI.

The only remaining issue as per subject; am I doing something wrong to warant a page refresh in order for badge to update?


8 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @devinedon When I publish a test notification, it increases the notification number on the badge and alerts without the need to refresh the page.

    I could not reproduce it. Can you please share a video screenshot or a gif that show the problem. Or you can send a demo project that contains that problem to [email protected].

  • User Avatar
    0
    devinedon created

    Thanks for putting this together! Really appreciate it. Will see if it does this for default notifications such as new user registrations etc... Will get back to you ASAP

    EDIT: Even new users registering dont show.. but strangly they dont even show in the Notifications page? Should they? "On a new user registered to the application." It is written to AbpNotifications

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @devinedon

    Yes, it should work like that for default notifications as well. Do you have any javascript error on browser console ?

  • User Avatar
    0
    devinedon created

    Hey,

    no javascript errors :/

    If it means anything, the chat works perfectly. Pushes through perfectly.

    Is it not problematic that Im triggering the push from a 3rd party application (Azure Function CosmosDB trigger)?

    using (var obj = Startup.iocManager.ResolveAsDisposable<AzFunctionAbpExecuter>())
    {
        await obj.Object.AddNewDeviceEventAppNotifier(deviceData);
    }
    
    public class AzFunctionAbpExecuter : ITransientDependency
    {
        private readonly IRepository<Tenant> _tenantRepository;
        private readonly IAppNotifier _appNotifier;
    
        public AzFunctionAbpExecuter(IRepository<Tenant> tenantRepository, IAppNotifier appNotifier)
        {
            _tenantRepository = tenantRepository;
            _appNotifier = appNotifier;
        }
    
        public async Task AddNewDeviceEventAppNotifier(SynapWare.CosmosDB.DeviceData data)
        {
            await _appNotifier.NewDeviceEventAsync(data);
        }
    }
    
    public async Task NewDeviceEventAsync(DeviceData deviceData)
    {
        var notificationData = new LocalizableMessageNotificationData(
            new LocalizableString(
                "NewDeviceEventNotificationMessage",
                SynapWareConsts.LocalizationSourceName
            )
        );
    
        notificationData["deviceSerial"] = deviceData.Serial;
        if (deviceData.aimEventData != null)
        {
            notificationData["eventType"] = deviceData.aimEventData.deviceEventDataType.ToString();
        }
    
        UserIdentifier user = new UserIdentifier(null, userId: 1);
        await _notificationPublisher.PublishAsync(AppNotificationNames.NewDeviceEvent, notificationData, userIds: new[] { user });
    }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Is it not problematic that Im triggering the push from a 3rd party application (Azure Function CosmosDB trigger)?

    Yes, this is the reason :)

    AspNet Zero's SignalR connection will not be aware of this request. In order to make this work, you can try Azure signalR Service.

  • User Avatar
    0
    devinedon created

    Thanks, I see from https://support.aspnetzero.com/QA/Questions/9129/Signal-R-send-custom-messages-to-Client-Side-using-azure-functionBlob-Triggered you say its supported from 8.6 and up. Is there any documentation to help me get going faster from ANZ?

  • User Avatar
    0
    devinedon created

    So making progress - web host is changed to use Azure Signal R and all looks good

    However, how would I access IApplicationbuilder in Azure Functions in order to map the endpoint (if you know of course). Could I get it via AbpModule? Just code below showing how you guys do it in an ASPNET Core application

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapHub<AbpCommonHub>(AppConsts.SignalRAbpCommonHubPath);
    }
    

    A host error has occurred during startup operation '39caf9b3-b3fa-472c-a351-6cc74d272ece'. [2020-12-14T11:48:02.356Z] func: Invalid host services. Microsoft.Azure.WebJobs.Script.WebHost: The following service registrations did not match the expected services: [2020-12-14T11:48:02.358Z] [Invalid] ServiceType: Microsoft.Extensions.Hosting.IHostedService, Lifetime: Singleton, ImplementationType: Microsoft.Azure.SignalR.HeartBeat, Microsoft.Azure.SignalR, Version=1.6.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60. Value cannot be null. (Parameter 'provider')

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If you follow https://docs.microsoft.com/en-us/azure/azure-signalr/signalr-quickstart-dotnet-core, you can enable Azure SignalR service in AspNet Zero.