A Canadian man who had pledged allegiance to the Islamic State group in a video was shot dead in a taxi after setting off an explosive device, police say.