The encode_data method should add a carriage return after the last contact. Currently, the contact_strings are joined with a "\n" but the last contact entry needs to have a CR after it (according to the AppConnect examples for using Activity).
Line 36 should look like this:
result += CGI.escape(contact_strings.join("\n") + "\n")