全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2061
推到 Plurk!
推到 Facebook!

iOS8 device token & VarToDateTime EVariantTypeCastError

答題得分者是:aftcast
anger625
一般會員


發表:1
回覆:1
積分:0
註冊:2015-07-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2015-07-03 18:32:41 IP:203.74.xxx.xxx 訂閱
大家好,小妹剛接觸Delphi不久,使用的版本是XE7,但是碰到了幾個問題,想請教各位高手

1.使用APNS功能要如何註冊device token?

已看過官方的這3篇教學

http://ppt.cc/hsqcW, http://ppt.cc/2LTiz, http://ppt.cc/k3kFF

Server會負責管理device token,不需要使用BAAS,但不知道在不設定TPushEvent 的 provider的情況下要怎麼取的device token

目前是參考

http://jamesjuantw.pixnet.net/blog/post/185648238

這篇的做法,雖然有成功出現詢問是否要接收通知的alert,但是device token是'',

不知是否是因為iOS 8 之後device token 無法用 didRegisterForRemoteNotificationsWithDeviceToken 取得的關係, 好像是要用 didRegisterUserNotificationSettings 只有查到C的寫法但是不知道怎麼轉換成Delphi

各位高手有其他方法可以取得device token嗎?
2.VarToDateTime 在iOS 平台似乎無法正常運作?

在64bit windows測試的時候 DT := VarToDateTime(time); 可以成功將'Sep 10, 2014 4:29:28 PM' 轉換成 TDateTime物件,

但是在iOS會出現"Could not convert variant of type (UnicodeString) into type (Date)"的錯誤,

也試過要用StrToDateTime轉換,但server傳來的'Sep 10, 2014 4:29:28 PM' 不知道是甚麼 format ,

一直無法轉換成功,大家在iOS上都是怎麼轉換日期的呢?
以上兩個問題,先謝過大家了!
編輯記錄
anger625 重新編輯於 2015-07-04 20:54:41, 註解 無‧
aftcast
站務副站長


發表:81
回覆:1485
積分:1763
註冊:2002-11-21

發送簡訊給我
#2 引用回覆 回覆 發表時間:2015-07-05 06:16:10 IP:49.218.xxx.xxx 訂閱
關於 ios 上 push 的做法,你可以在我的社群中的 ios 專區 與 anroid 專區看到如何做。基本上,anroid上的做法與 ios 的做法一樣。若你只想單獨使用 ios ,那麼只要略過 gcmappid 的部份,讓它空白就可以。
我在 stackoverflow上也有po文與圖。可參考。(雖然是講 anroid,但 ios是一樣的做法,除了 gcmappid的部份不要去理它即可)。

http://stackoverflow.com/questions/25205478/issue-with-gcm-push-notification-service-delphi-xe6/27690786#27690786

另外,你也要參考一下:
http://docwiki.embarcadero.com/RADStudio/XE7/en/Setting_Up_the_Messaging_Service

http://docwiki.embarcadero.com/RADStudio/XE7/en/Creating_the_Application

至於 ios push server 的實作,我暫還沒放到我的 g 社群。但可參考本站會員 james 的blog:

http://jamesjuantw.pixnet.net/blog/post/185648259
------


蕭沖
--All ideas are worthless unless implemented--

C++ Builder Delphi Taiwan G+ 社群
http://bit.ly/cbtaiwan
anger625
一般會員


發表:1
回覆:1
積分:0
註冊:2015-07-03

發送簡訊給我
#3 引用回覆 回覆 發表時間:2015-07-11 11:32:35 IP:203.74.xxx.xxx 訂閱
首先感謝副站長的回應,我有加入您的論壇也以關鍵字push搜索了一下文章,不過只有看到android的demo但是沒有原始碼的部分,因此不知道在實做上要怎麼進行

目前試了以下幾種方法

1.參考您在stackoverflow上的教學,並使用以下程式碼實做

[code delphi]
PushEvents1.Active := True;
PushEvents1.RegisterDevice; //<-error:device token is not available this application may not be configured to support push
if (PushEvents1.DeviceRegistered) then
ShowMessage(PushEvents1.DeviceToken);
[/code]
但是在PushEvents1.RegisterDevice; 會出現device token is not available this application may not be configured to support push的error

2.create PushEvents
[code delphi]
var
pushEvent :TPushEvents;
begin
pushEvent := TPushEvents.Create;
pushEvent.Active := True;//<-erreo:provider is nil
[/code]
在pushEvent.Active := True;這行出現錯誤說provider是nil
因為KinveyProvider沒有設帳號密碼?

3.參考james的blog
這個做法好像跟您的方法比較不同,而Apple.RemoteNotification.pas
didRegisterForRemoteNotificationsWithDeviceToken 而iOS8好像要用didRegisterUserNotificationSettings
http://stackoverflow.com/questions/24426090/get-device-token-in-ios-8
但是我不會寫C所以不知道要怎麼改

以上還請大家不吝指教,謝謝。
編輯記錄
anger625 重新編輯於 2015-07-12 23:06:05, 註解 無‧
anger625 重新編輯於 2015-07-12 23:06:57, 註解 無‧
anger625 重新編輯於 2015-07-12 23:11:04, 註解 無‧
anger625 重新編輯於 2015-07-13 09:59:22, 註解 無‧
anger625 重新編輯於 2015-07-13 10:01:31, 註解 無‧
系統時間:2024-05-09 6:19:19
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!