Commit 106bf6c9 authored by Wei Han's avatar Wei Han

readme update

parent b3b7d2a9
......@@ -4,6 +4,10 @@
<dict>
<key>files</key>
<dict>
<key>Assets.car</key>
<data>
KnMHH8GU4NZESWbs6/0uU5WX8uA=
</data>
<key>Headers/QmsPlugin.h</key>
<data>
k1ElB+OnAYDlAZsTB5il2X25Zbo=
......@@ -23,6 +27,13 @@
</dict>
<key>files2</key>
<dict>
<key>Assets.car</key>
<dict>
<key>hash2</key>
<data>
aLAhYopvL1Lb4CTMG5A8x8RAmnkpXwHQbjsJdpq8gYg=
</data>
</dict>
<key>Headers/QmsPlugin.h</key>
<dict>
<key>hash2</key>
......
......@@ -4,6 +4,10 @@
<dict>
<key>files</key>
<dict>
<key>Assets.car</key>
<data>
KnMHH8GU4NZESWbs6/0uU5WX8uA=
</data>
<key>Headers/QmsPlugin.h</key>
<data>
k1ElB+OnAYDlAZsTB5il2X25Zbo=
......@@ -23,6 +27,13 @@
</dict>
<key>files2</key>
<dict>
<key>Assets.car</key>
<dict>
<key>hash2</key>
<data>
aLAhYopvL1Lb4CTMG5A8x8RAmnkpXwHQbjsJdpq8gYg=
</data>
</dict>
<key>Headers/QmsPlugin.h</key>
<dict>
<key>hash2</key>
......
......@@ -4,7 +4,7 @@
@interface DashboardAPIClient : NSObject
+ (void)fetchDashboardSummary:(void (^)(NSDictionary *data))completion;
+ (void)fetchAnnouncements:(void (^)(NSArray *data))completion;
+ (void)fetchAnnouncement:(void (^)(NSArray *data))completion;
+ (void)fetchAppointments:(void (^)(NSArray *data))completion;
+ (void)fetchIssues:(void (^)(NSArray *data))completion;
+ (void)fetchHeaderInfo:(void (^)(NSDictionary *data))completion;
......
......@@ -15,18 +15,6 @@
}] resume];
}
+ (void)fetchAnnouncements:(void (^)(NSArray *))completion {
NSURL *url = [NSURL URLWithString:@"https://jsonplaceholder.typicode.com/posts?_limit=5"];
[[[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { completion(nil); return; }
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
completion(json);
});
}] resume];
}
+ (void)fetchAppointments:(void (^)(NSArray *))completion {
NSURL *url = [NSURL URLWithString:@"https://jsonplaceholder.typicode.com/todos?_limit=5"];
[[[NSURLSession sharedSession] dataTaskWithURL:url
......@@ -68,42 +56,48 @@
}
+ (void)fetchDashboardInfo:(void (^)(NSDictionary *data, NSError *error))completion {
NSString *baseURL = @"https://kitadev.commudesk.com/api/owner/plan/getIssueUpdateAppointmentInfo";
NSString *token = @"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzdWIiOjIxNzAsImlzcyI6Imh0dHBzOi8va2l0YWRldi5jb21tdWRlc2suY29tL2FwaS9vd25lci9hdXRoL3Bhc3N3b3JkbGVzc19sb2dpbiIsImlhdCI6MTc2MDMxNTM1MiwiZXhwIjoyMDc1ODg0ODcyLCJuYmYiOjE3NjAzMTUzNTIsImp0aSI6IktoQmNyQnJEdDVNdDZlWmMifQ.JnxGbZ7hTeoOr6oibIzZMphgyKtTo2Aq9Efx6mrGfFA";
// 👇 Append token as query parameter
NSString *fullURL = [NSString stringWithFormat:@"%@?token=%@", baseURL, token];
NSURL *url = [NSURL URLWithString:fullURL];
NSString *urlString = @"https://kitadev.commudesk.com/api/owner/plan/getIssueUpdateAppointmentInfo";
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
NSDictionary *body = @{
@"os": @"AND",
@"drawing_plan_id": @135,
@"information": @{
@"OS": @"AND",
@"IMEI": @"AND:2a2f13ff17b1cbb5",
@"OS_VERSION": @"35",
@"MODEL": @"2306EPN60G",
@"APP_VERSION": @"1.22.26"
}
// 🪪 Authorization header
NSString *token = @"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzdWIiOjIxNzAsImlzcyI6Imh0dHBzOi8va2l0YWRldi5jb21tdWRlc2suY29tL2FwaS9vd25lci9hdXRoL3Bhc3N3b3JkbGVzc19sb2dpbiIsImlhdCI6MTc2MDMxNTM1MiwiZXhwIjoyMDc1ODg0ODcyLCJuYmYiOjE3NjAzMTUzNTIsImp0aSI6IktoQmNyQnJEdDVNdDZlWmMifQ.JnxGbZ7hTeoOr6oibIzZMphgyKtTo2Aq9Efx6mrGfFA";
[request setValue:[NSString stringWithFormat:@"Bearer %@", token] forHTTPHeaderField:@"Authorization"];
// 🧱 Create multipart form-data body
NSString *boundary = [NSString stringWithFormat:@"Boundary-%@", [[NSUUID UUID] UUIDString]];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
// Helper block to append fields
void (^appendFormField)(NSString *, NSString *) = ^(NSString *key, NSString *value) {
[body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"%@\r\n", value] dataUsingEncoding:NSUTF8StringEncoding]];
};
NSError *jsonError = nil;
NSData *bodyData = [NSJSONSerialization dataWithJSONObject:body options:0 error:&jsonError];
if (jsonError) {
if (completion) completion(nil, jsonError);
return;
}
request.HTTPBody = bodyData;
// Add form fields
appendFormField(@"data[os]", @"AND");
appendFormField(@"data[drawing_plan_id]", @"135");
NSString *infoJson = @"{\"OS\":\"AND\",\"IMEI\":\"AND:2a2f13ff17b1cbb5\",\"OS_VERSION\":\"35\",\"MODEL\":\"2306EPN60G\",\"APP_VERSION\":\"1.22.26\"}";
appendFormField(@"data[information]", infoJson);
NSLog(@"🌍 Final URL: %@", url.absoluteString);
NSLog(@"📦 Body: %@", [[NSString alloc] initWithData:bodyData encoding:NSUTF8StringEncoding]);
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request
request.HTTPBody = body;
// 🌍 Debug logs
NSLog(@"🌍 URL: %@", urlString);
NSLog(@"🪪 Authorization: Bearer %@", token);
NSLog(@"📦 Body:\n%@", [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding]);
NSURLSessionDataTask *task = [[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"❌ Network error: %@", error);
......@@ -121,6 +115,64 @@
});
}
}];
[task resume];
}
+ (void)fetchAnnouncement:(void (^)(NSArray *data))completion {
NSURL *url = [NSURL URLWithString:
@"https://kitadev.commudesk.com/api/announcement?token=YOUR_TOKEN_HERE"];
NSDictionary *body = @{
@"data": @{
@"os": @"iOS",
@"information": @{
@"OS": @"iOS",
@"IMEI": @"iOS:1234567890",
@"OS_VERSION": [[UIDevice currentDevice] systemVersion],
@"MODEL": [[UIDevice currentDevice] model],
@"APP_VERSION": [[[NSBundle mainBundle] infoDictionary]
objectForKey:@"CFBundleShortVersionString"]
}
}
};
NSError *jsonError;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:body options:0 error:&jsonError];
if (jsonError) {
NSLog(@"❌ JSON serialization failed: %@", jsonError);
if (completion) completion(@[]);
return;
}
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
request.HTTPBody = jsonData;
NSURLSessionDataTask *task = [[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"❌ Request failed: %@", error.localizedDescription);
if (completion) completion(@[]);
return;
}
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"✅ Announcement API response:\n%@", json);
NSDictionary *appData = json[@"AppData"];
if ([appData[@"status"] isEqualToString:@"success"]) {
NSArray *announcements = json[@"Data"];
NSLog(@"📣 Got %lu announcements", (unsigned long)announcements.count);
if (completion) completion(announcements);
} else {
NSLog(@"⚠️ Announcement fetch failed: %@", appData[@"message"]);
if (completion) completion(@[]);
}
}];
[task resume];
}
......
{
"images" : [
{
"filename" : "overlay.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -4,6 +4,10 @@
<dict>
<key>files</key>
<dict>
<key>Assets.car</key>
<data>
KnMHH8GU4NZESWbs6/0uU5WX8uA=
</data>
<key>Headers/QmsPlugin.h</key>
<data>
k1ElB+OnAYDlAZsTB5il2X25Zbo=
......@@ -23,6 +27,13 @@
</dict>
<key>files2</key>
<dict>
<key>Assets.car</key>
<dict>
<key>hash2</key>
<data>
aLAhYopvL1Lb4CTMG5A8x8RAmnkpXwHQbjsJdpq8gYg=
</data>
</dict>
<key>Headers/QmsPlugin.h</key>
<dict>
<key>hash2</key>
......
......@@ -4,6 +4,10 @@
<dict>
<key>files</key>
<dict>
<key>Assets.car</key>
<data>
KnMHH8GU4NZESWbs6/0uU5WX8uA=
</data>
<key>Headers/QmsPlugin.h</key>
<data>
k1ElB+OnAYDlAZsTB5il2X25Zbo=
......@@ -23,6 +27,13 @@
</dict>
<key>files2</key>
<dict>
<key>Assets.car</key>
<dict>
<key>hash2</key>
<data>
aLAhYopvL1Lb4CTMG5A8x8RAmnkpXwHQbjsJdpq8gYg=
</data>
</dict>
<key>Headers/QmsPlugin.h</key>
<dict>
<key>hash2</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment