언어 설정

Menu
Sites
Language
Send SMS Message from Native Widget on Gear S2 SM-R720

Hello,

I am developing a widget with a single button to send a specific text message to a specific number with one touch, but I've run into an issue.

I've been all across the internet trying to solve a very simple problem:

developer.samsung.com/forum/board/thread/view.do?boardName=SDK&messageId=279171&startId=zzzzz~&searchType=ALL&searchText=com.samsung.message

developer.samsung.com/forum/board/thread/view.do?boardName=SDK&messageId=277363&startId=zzzzz~&searchType=ALL&searchText=com.samsung.message

webcache.googleusercontent.com/search?q=cache:gV5sinlRGngJ:https://developer.tizen.org/ko/forums/web-application-development/how-call-up-systems-sms-compose-capabilities%3Flangswitch%3Dko+&cd=1&hl=en&ct=clnk&gl=us

developer.tizen.org/community/code-snippet/search-category/all?category_path=/community/code-snippet/native-code-snippet/all&title=SMS&field_description_value=SMS&body_value=SMS&field_select_profile_tid_i18n%5B877%5D=877

I'm running the application on a Gear S2 SM-R720 running software version R720XXU2CPC5.

I've tried using the app_control_id "com.samsung.message" and "tizen.messages". "tizen.messages" results in an APP_NOT_FOUND error, whereas the first one simply launches the messaging app.

1) Is there a better way to do this?

2) How do I force-install the tizen.messages app?

2) Where can I find the source code / API documentation / manifest.xml on com.samsung.message?

Now, the code that I've developed (the number has been masked for privacy:

static void
sent_msg_cb(messages_sending_result_e result, void *user_data)
{
    if (MESSAGES_SENDING_SUCCEEDED == result) {
        dlog_print(DLOG_DEBUG, LOG_TAG, "Message sending succeeded");
    } else {
        dlog_print(DLOG_DEBUG, LOG_TAG, "Message sending failed");
    }
}

static void _button_click_cb(void *data, Evas_Object *button, void *ev) {
    bool sendText = false;

	system_info_get_platform_bool("tizen.org/feature/network.telephony", &sendText);
	system_info_get_platform_bool("tizen.org/feature/network.telephony.sms", &sendText);

	if(sendText) {
		error_code = messages_open_service(&service_handle);

		if (error_code == MESSAGES_ERROR_NONE) {
			int error_code2;
			messages_message_h msg_hndl = NULL;

			/* Create an SMS message handle */
			error_code2 = messages_create_message(MESSAGES_TYPE_SMS, &msg_hndl);
			if (error_code2 != MESSAGES_ERROR_NONE) {
				log_message_error_code("Failed to create message: ", error_code2);
			}

			error_code2 = messages_add_address(msg_hndl, "7319260071", MESSAGES_RECIPIENT_TO);
			if (error_code2 != MESSAGES_ERROR_NONE) {
				log_message_error_code("Failed to add recipient address: ", error_code2);
			}

			error_code2 = messages_set_text(msg_hndl, ":*");
			if (error_code2 != MESSAGES_ERROR_NONE) {
				log_message_error_code("Failed to set message text: ", error_code2);
			}

			error_code2 = messages_send_message(service_handle, msg_hndl, true,
					sent_msg_cb, NULL);
			if (error_code2 != MESSAGES_ERROR_NONE) {
				log_message_error_code("Failed to send message: ", error_code2);

			}

		} else {
			log_message_error_code("Failed to initialize message service: ", error_code);
			switch (error_code) {
			case MESSAGES_ERROR_OUT_OF_MEMORY: /**< Out of memory */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_OUT_OF_MEMORY");
				break;
			case MESSAGES_ERROR_INVALID_PARAMETER: /**< Invalid parameter */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_INVALID_PARAMETER");
				break;
			case MESSAGES_ERROR_SERVER_NOT_READY: /**< Server is not read */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_SERVER_NOT_READY");
				break;
			case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: /**< Communication with server failed */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED");
				break;
			case MESSAGES_ERROR_OUT_OF_RANGE: /**< Index out of range */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_OUT_OF_RANGE");
				break;
			case MESSAGES_ERROR_SENDING_FAILED: /**< Sending a message failed */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_SENDING_FAILED");
				break;
			case MESSAGES_ERROR_OPERATION_FAILED: /**< Messaging operation failed */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_OPERATION_FAILED");
				break;
			case MESSAGES_ERROR_NO_SIM_CARD: /**< No SIM Card */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_NO_SIM_CARD");
				break;
			case MESSAGES_ERROR_NO_DATA: /**< No data available */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_NO_DATA");
				break;
			case MESSAGES_ERROR_PERMISSION_DENIED: /**< Permission denied */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_PERMISSION_DENIED");
				break;
			case MESSAGES_ERROR_NOT_SUPPORTED:	/**< Not supported */
				log_message(DLOG_ERROR,"MESSAGES_ERROR_NOT_SUPPORTED");
				break;
			default:
				log_message_error_code("Unknown: ", error_code);
			}
		}

		messages_close_service(service_handle);
		service_handle = NULL;
	} else {
		app_control_h app_control = NULL;
		app_control_create(&app_control);
		app_control_set_operation(app_control, APP_CONTROL_OPERATION_COMPOSE);
		app_control_set_app_id(app_control, "tizen.messages");
		app_control_add_extra_data(app_control, APP_CONTROL_DATA_TO, "+10000000000");
		app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, ":*");

		if(app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE) {
			log_message(DLOG_DEBUG, "SMS view launched!");
		}

		app_control_destroy(app_control);
	}
}