Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

App Uninstall Event Not Firing when app is deleted from Site Contents. SharePoint Online

$
0
0

I am encountering a very strange issues with App Events in Provide Hosted Apps.

I have some logics that execute when user uninstall the app from the site. This code used to work fine but suddenly, uninstalling/deleting app from the Site Contents does not fire/trigger the app uninstall event. They remote endpoint is not being called.

I have created a dummy project to test it out and deploy to a SharePoint Developer Account (App is hosted in Azure with proper certificates). I noticed the uninstall event is only being triggered when I delete the app from the "Apps in Testing" list. Removing the app from Site Contents does not trigger the event.

Here is how my sample appmanifest look.

<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest"
     Name="demoRemoteAppEvent"
     ProductID="{b1f847a9-15f3-40b9-887d-ad38434c0cef}"
     Version="1.0.0.0"
     SharePointMinVersion="15.0.0.0"><Properties><Title>demoRemoteAppEvent</Title><StartPage>~remoteAppUrl/Pages/Default.aspx?{StandardTokens}</StartPage><UninstallingEventEndpoint>~remoteAppUrl/appeventreceiver.svc</UninstallingEventEndpoint><InstalledEventEndpoint>~remoteAppUrl/AppEventReceiver.svc</InstalledEventEndpoint></Properties><AppPrincipal><RemoteWebApplication ClientId="*"  /></AppPrincipal><AppPermissionRequests AllowAppOnlyPolicy="true"><AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Manage" /></AppPermissionRequests></App>

And my AppEventReceiver endpoint is the default we get when we enable app events as below.

    public class AppEventReceiver : IRemoteEventService
    {
        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult result = new SPRemoteEventResult();

            using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
            {
                if (clientContext != null)
                {
                    clientContext.Load(clientContext.Web);
                    clientContext.ExecuteQuery();
                }
            }

            return result;
        }

        public void ProcessOneWayEvent(SPRemoteEventProperties properties)
        {
            // This method is not used by app events
        }
    }

Note: When the app is side loaded from the app catalog, uninstall event is not triggered at all, whether you remove from the Site Contents or delete it from the app catalog.

Search around the Web have not been useful so far.

Hope someone here can give some ideas.

Thanks in advance.


Viewing all articles
Browse latest Browse all 8089

Trending Articles