To test for halide ions silver nitrate is added to a solution of the halide.A precipitate forms.This test cannot be used to test for fluorides as silver fluoride is soluble. Dilute nitric acid is added to make sure that other anions e.g. carbonates are removed and do not form precipitates.Ag+ (aq) + X-(aq) → AgX (s)

With ammonia:AgCl (s) + 2NH3 (aq) → [Ag(NH3)2]+ (aq) + Cl- (aq)
With ammonia:AgCl (s) + 2NH3 (aq) → [Ag(NH3)2]+ (aq) + Cl- (aq)