A device for selectively measuring the presence of magnesium ions comprising: a substrate; a sensor layer comprising a luminoionophore that is capable of binding magnesium ions and that is optionally immobilized on a solid support; and a scavenging layer that preferentially binds to calcium ions in the presence of both magnesium ions and calcium ions; wherein the luminoionophore exhibits luminescence at a first intensity and wherein upon contacting said device with a solution containing magnesium ions the luminoionophore exhibits luminescence at a second intensity that is different from the first intensity in an amount that is in proportion to the concentration of magnesium ion present in the solution; and wherein the luminoionophore conforms to the following formula I: wherein, A, B, and C are independently selected from the group consisting of hydrogen, -OCH 2 COOR', and -N(CH 2 COOR') 2, wherein one or more of A, B and C is independently selected from the group consisting of -OCH 2 COOR' and -N(CH 2 COOR') 2, wherein R' is selected from the group consisting of hydrogen, C 1 -C 12 -alkyl, and a cation; X and Y, in each instance where they appear, are independently selected from the group consisting of hydrogen, hydroxyl, halogen, ethoxy, methoxy, amine and -COOR'; v is an integer selected from 0, 1, 2, 3 and 4; and Z is a luminophoric moiety of Formula (a): wherein, R 3, R 4, R 5, R 6, R 7, R 8, and R 9 are independently selected from the group consisting of hydrogen, a lipophilic group, a hydrophilic group and a reactive group for coupling to a polymer; wherein at least one of R 3, R 4, R 5, R 6, R 7, and R 8 is a -NH- group through which Z is bound to the group - v -. a substrate; a sensor layer comprising a luminoionophore that is capable of binding magnesium ions and that is optionally immobilized on a solid support; and a scavenging layer that preferentially binds to calcium ions in the presence of both magnesium ions and calcium ions; wherein the luminoionophore exhibits luminescence at a first intensity and wherein upon contacting said device with a solution containing magnesium ions the luminoionophore exhibits luminescence at a second intensity that is different from the first intensity in an amount that is in proportion to the concentration of magnesium ion present in the solution; and wherein the luminoionophore conforms to the following formula I: wherein, A, B, and C are independently selected from the group consisting of hydrogen, -OCH 2 COOR', and -N(CH 2 COOR') 2, wherein one or more of A, B and C is independently selected from the group consisting of -OCH 2 COOR' and -N(CH 2 COOR') 2, wherein R' is selected from the group consisting of hydrogen, C 1 -C 12 -alkyl, and a cation; X and Y, in each instance where they appear, are independently selected from the group consisting of hydrogen, hydroxyl, halogen, ethoxy, methoxy, amine and -COOR'; v is an integer selected from 0, 1, 2, 3 and 4; and Z is a luminophoric moiety of Formula (a): wherein, R 3, R 4, R 5, R 6, R 7, R 8, and R 9 are independently selected from the group consisting of hydrogen, a lipophilic group, a hydrophilic group and a reactive group for coupling to a polymer; wherein at least one of R 3, R 4, R 5, R 6, R 7, and R 8 is a -NH- group through which Z is bound to the group - v -. A, B, and C are independently selected from the group consisting of hydrogen, -OCH 2 COOR', and -N(CH 2 COOR') 2, wherein one or more of A, B and C is independently selected from the group consisting of -OCH 2 COOR' and -N(CH 2 COOR') 2, wherein R' is selected from the group consisting of hydrogen, C 1 -C 12 -alkyl, and a cation; X and Y, in each instance where they appear, are independently selected from the group consisting of hydrogen, hydroxyl, halogen, ethoxy, methoxy, amine and -COOR'; v is an integer selected from 0, 1, 2, 3 and 4; and Z is a luminophoric moiety of Formula (a): wherein, R 3, R 4, R 5, R 6, R 7, R 8, and R 9 are independently selected from the group consisting of hydrogen, a lipophilic group, a hydrophilic group and a reactive group for coupling to a polymer; wherein at least one of R 3, R 4, R 5, R 6, R 7, and R 8 is a -NH- group through which Z is bound to the group - v -.