What you did was create a masterpage in the appweb. If you want it in the host web, you'll have to copy the masterpage to the host web's gallery. If you have a provider hosted app, this code would work to do so:
using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, contextToken, Request.Url.Authority))
{
var site = clientContext.Site;
//Upload master page from app web. Masterpage will be in the form of text since we only care about the markup and the masterpage should be already tested and fully functional within sharepoint
//If masterpage was left as a masterpage file then there will be compile errors due to missing dll and references
var streamMaster = this.OpenFile("/MasterPage/seattleCustom.txt");
//Get context to the master page gallery. Make sure the target site has Publishing features activated
List gallery = site.RootWeb.Lists.GetByTitle("Master Page Gallery");
//Create File Creation Information Object
FileCreationInformation fcimaster = new FileCreationInformation();
fcimaster.ContentStream = streamMaster;
fcimaster.Url = "MPSHome.master";
fcimaster.Overwrite = true;
//Add File to Master Page Gallery
Microsoft.SharePoint.Client.File newFile = gallery.RootFolder.Files.Add(fcimaster);
clientContext.Load(newFile);
clientContext.ExecuteQuery();
//Get Masterpage from Gallery to set content type and metadata using caml query
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Contains><FieldRef Name='FileLeafRef'/><Value Type='Text'>" + fcimaster.Url + "</Value>" + "</Contains></Where></Query><RowLimit>100</RowLimit></View>";
Microsoft.SharePoint.Client.ListItemCollection collListItem = gallery.GetItems(camlQuery);
clientContext.Load(collListItem);
clientContext.ExecuteQuery();
//If not checked out, Check out File
foreach (Microsoft.SharePoint.Client.ListItem item in collListItem)
{
clientContext.Load(item.File);
clientContext.ExecuteQuery();
if (item.File.CheckOutType == CheckOutType.None)
{
item.File.CheckOut();
}
//Get the ASP NET Master Page Content Type using helper function
var masterPageCT = GetContentType(clientContext, gallery, "ASP NET Master Page");
//Set Content Type, UI version, and Description. Check in and Publish
item["ContentTypeId"] = masterPageCT.Id.ToString();
item["UIVersion"] = Convert.ToString(15);
item["MasterPageDescription"] = "This is the custom MPS MasterPage";
item.Update();
item.File.CheckIn("Updated Content Type", CheckinType.MajorCheckIn);
item.File.Publish("Updated Metadata");
clientContext.Load(item);
clientContext.ExecuteQuery();
}
}
Function to get content type
private ContentType GetContentType(ClientContext ctx, List docs, string contentType)
{
ContentTypeCollection listContentTypes = docs.ContentTypes;
ctx.Load(listContentTypes, types => types.Include
(type => type.Id, type => type.Name, type => type.Parent));
var result = ctx.LoadQuery(listContentTypes.Where(c => c.Name == contentType));
ctx.ExecuteQuery();
ContentType targetDocumentSetContentType = result.FirstOrDefault();
return targetDocumentSetContentType;
}
I got the code from here. If you have a SharePoint-hosted app, then this will need to be converted to JSOM.