This post is article 16 from the 30 Articles App series for SharePoint
Today I will talk about how to handle app events with Remote Event Receivers !!
Do you need to perform some precise tasks when your app is installed or upgraded, well then you must use Remote Event Receivers.
Remote Event Receivers are only available to cloud(auto/provider both) -hosted app but not to SharePoint-Hosted app. [ When you try to add event receivers to SharePoint-hosted app it will be automatically converted into auto-hosted app !!]
How to create event receiver for your app-events:
Go to your SharePoint-app project -> Right click and go to property => Now set value =true to “Handle App Installed” and rest of the events that you want to handle.
This will generate AppEventReceiver.svc service in your web-project and also make necessary changes to app-manifest as below:
In the ProcessEvent method you can handle app related events… App Installed, App Upgraded, App Uninstalled
Pass the second variable true for SPAppWeb-clientcontext and false for SPHostWeb -clientcontext to the CreateAppEventClientContext method of TokenHelper.
Hope that helps.
Hi Aanu,
In this article they are explaining only for SharePoint-hosted apps for remote event receivers.
http://blogs.technet.com/b/sharepointdevelopersupport/archive/2013/03/13/how-to-create-a-remote-event-receiver-for-a-sharepoint-hosted-app.aspx
But in your post you said like it will not applied for SharePoint-Hosted apps. I got confused here.
Can you please explain any mis understanding from my side?
HI Suresh,
When you try to add remote event receivers a SharePoint-hosted app, it will automatically generate a web application to host the services and hence it is then converted in to auto-hosted app which can still have SharePoint entry point.
Hope that helps..
Aanu