A novel fluorescent probe NIPF was synthesized by the Suzuki reaction to recognize Cu2+ and CN−. With the addition of Cu2+, NIPF exhibited strong fluorescence quenching (90 % for NIPF) with a Ksv value of 3.4 × 106 M−1 and a detection limit of 9.04 × 10−10 M. Subsequently, CN− was added to the NIPF-Cu2+ solution, and [Cu(CN)x]n− was formed due to the strong interaction between Cu2+ and CN− leading to fluorescence recovery (89 % for NIPF-Cu2+). In addition, a detection limit of 3.6 × 10−8 M was obtained by fluorescence titration. Meanwhile, it was demonstrated that the sensor achieved 93 %–105 % recovery of Cu2+ in the tested environmental samples, and the practicability of Cu2+ and CN− detection were verified using hydrogels test, with significant color changes observed under 365 nm light. Accordingly, the fluorescent probe NIPF was used to recognize Cu2+ and CN− by the “on-off-on” sensors.